forked from snxraven/p2ns
current branding
This commit is contained in:
@@ -32,7 +32,7 @@ async function serveFile(filePath, res) {
|
||||
}
|
||||
|
||||
async function serveAdminFrontendAsset(urlPath, res) {
|
||||
if (!/^\/(?:ui\/[\w.-]+\.js|[\w.-]+\.(?:css|js|svg|ico|png|json|webmanifest))$/.test(urlPath)) {
|
||||
if (!/^\/(?:ui\/[\w.-]+\.js|branding\/[\w.-]+\.png|[\w.-]+\.(?:css|js|svg|ico|png|json|webmanifest))$/.test(urlPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,16 +90,12 @@ async function handleStaticRoutes(req, res) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (method === 'GET') {
|
||||
const served = await serveAdminFrontendAsset(urlPath, res);
|
||||
if (served) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (method === 'GET' && urlPath === '/favicon.ico') {
|
||||
if (method === 'GET' && (urlPath === '/favicon.ico' || urlPath === '/apple-touch-icon.png')) {
|
||||
const faviconFile = urlPath === '/favicon.ico'
|
||||
? pathModule.join(ADMIN_FRONTEND_DIR, 'favicon.ico')
|
||||
: pathModule.join(ADMIN_FRONTEND_DIR, 'branding', 'p2ns-favicon-192.png');
|
||||
try {
|
||||
await serveFile(pathModule.join(ADMIN_FRONTEND_DIR, 'favicon.svg'), res);
|
||||
await serveFile(faviconFile, res);
|
||||
} catch (err) {
|
||||
res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
|
||||
res.end('Not Found');
|
||||
@@ -107,6 +103,13 @@ async function handleStaticRoutes(req, res) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (method === 'GET') {
|
||||
const served = await serveAdminFrontendAsset(urlPath, res);
|
||||
if (served) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user