Skip to content

Commit 780f3c5

Browse files
committed
fix: add trailing slash on sitemap links
1 parent a92d754 commit 780f3c5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pwa/app/sitemap.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { getRootUrl } from "utils";
1212

1313
const basePath = getRootUrl();
1414

15+
const addTrailingSlashIfNecessary = (str: string) =>
16+
str.charAt(str.length - 1) === "/" ? str : `${str}/`;
17+
1518
function createLocalePath(locale: Locale, path: string, edition?: string) {
1619
const baseLocalePath =
1720
i18n.defaultLocale === locale ? basePath : `${basePath}/${locale}`;
@@ -54,7 +57,7 @@ async function getAllConRoutes() {
5457
routes.push(createLocalePath(locale, `con/${edition}/${legal}`));
5558
}
5659
}
57-
return routes;
60+
return routes.map((route) => addTrailingSlashIfNecessary(route));
5861
}
5962

6063
async function getAllStandardRoutes() {
@@ -92,13 +95,14 @@ async function getAllStandardRoutes() {
9295
}
9396
}
9497

95-
return routes;
98+
return routes.map((route) => addTrailingSlashIfNecessary(route));
9699
}
97100

98101
export default async function sitemap() {
99102
const allLinks = [
100-
...(await getAllConRoutes()),
103+
basePath,
101104
...(await getAllStandardRoutes()),
105+
...(await getAllConRoutes()),
102106
];
103107
return allLinks.map((path) => ({ url: path }));
104108
}

0 commit comments

Comments
 (0)