Add BASE_PATH handling to expectedCanonicalForFile function

This commit is contained in:
alam00000
2026-08-14 19:19:26 +05:30
parent 61fde80a90
commit ee17fa8760
+2
View File
@@ -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 NOINDEX_ALLOWLIST = new Set(['404.html', 'wasm-settings.html']);
@@ -72,6 +73,7 @@ function expectedCanonicalForFile(rel) {
const baseName = fileName.replace(/\.html$/, '');
const slug = baseName === 'index' ? '' : baseName;
const segments = [SITE_URL];
if (BASE_PATH) segments.push(BASE_PATH.replace(/^\//, ''));
if (slug) segments.push(slug);
return segments.join('/').replace(/\/+$/, '') || SITE_URL;
}