diff --git a/tools/adev-patches/replace-canonical-host.patch b/tools/adev-patches/replace-canonical-host.patch index fc1994f07..23a11fc8a 100644 --- a/tools/adev-patches/replace-canonical-host.patch +++ b/tools/adev-patches/replace-canonical-host.patch @@ -11,17 +11,7 @@ index ee21c0a837..afe9b7819c 100644 /** * Information about the deployment of this application. -@@ -20,7 +20,9 @@ export class HeaderService { - setCanonical(absolutePath: string): void { - const pathWithoutFragment = this.normalizePath(absolutePath).split('#')[0]; - const fullPath = `${ANGULAR_DEV}/${pathWithoutFragment}`; -- this.document.querySelector('link[rel=canonical]')?.setAttribute('href', fullPath); -+ // Cloudflare Pages redirects /foo to /foo/ -+ const fullPathWithSlash = fullPath.endsWith('/') ? fullPath : `${fullPath}/`; -+ this.document.querySelector('link[rel=canonical]')?.setAttribute('href', fullPathWithSlash); - } - - private normalizePath(path: string): string { + diff --git a/adev/src/index.html b/adev/src/index.html index f6d4c0eb48..d0087eaf2a 100644 --- a/adev/src/index.html diff --git a/tools/lib/sitemap.ts b/tools/lib/sitemap.ts index c8e2a9273..0a81b0621 100644 --- a/tools/lib/sitemap.ts +++ b/tools/lib/sitemap.ts @@ -16,7 +16,7 @@ export async function generateSitemap(distPath: string) { }); for (const file of htmlFiles) { - stream.write({ url: file.replace(/index\.html$/, '') }); + stream.write({ url: file.replace(/\/index\.html$/, '') }); } stream.end();