mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-08-17 21:25:47 +02:00
Add BASE_PATH handling to expectedCanonicalForFile function
This commit is contained in:
@@ -11,6 +11,7 @@ const SITE_URL = (process.env.SITE_URL || 'https://www.bentopdf.com').replace(
|
|||||||
/\/+$/,
|
/\/+$/,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
const BASE_PATH = (process.env.BASE_URL || '/').replace(/\/$/, '');
|
||||||
const HOST = new URL(SITE_URL).hostname;
|
const HOST = new URL(SITE_URL).hostname;
|
||||||
|
|
||||||
const NOINDEX_ALLOWLIST = new Set(['404.html', 'wasm-settings.html']);
|
const NOINDEX_ALLOWLIST = new Set(['404.html', 'wasm-settings.html']);
|
||||||
@@ -72,6 +73,7 @@ function expectedCanonicalForFile(rel) {
|
|||||||
const baseName = fileName.replace(/\.html$/, '');
|
const baseName = fileName.replace(/\.html$/, '');
|
||||||
const slug = baseName === 'index' ? '' : baseName;
|
const slug = baseName === 'index' ? '' : baseName;
|
||||||
const segments = [SITE_URL];
|
const segments = [SITE_URL];
|
||||||
|
if (BASE_PATH) segments.push(BASE_PATH.replace(/^\//, ''));
|
||||||
if (slug) segments.push(slug);
|
if (slug) segments.push(slug);
|
||||||
return segments.join('/').replace(/\/+$/, '') || SITE_URL;
|
return segments.join('/').replace(/\/+$/, '') || SITE_URL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user