Skip to content

Commit 2bb79d0

Browse files
author
Philipp Zerelles
committed
fix: normalize trailing slash in prerender (#1486)
1 parent a66affe commit 2bb79d0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/kit/src/core/adapt/prerender.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,26 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
9090
}
9191
});
9292

93+
/**
94+
* @param {string} path
95+
*/
96+
function normalizeTrailingSlash(path) {
97+
if (config.kit.trailingSlash === 'always') {
98+
return path.endsWith('/') ? path : `${path}/`;
99+
}
100+
if (config.kit.trailingSlash === 'never') {
101+
return !path.endsWith('/') || path === '/' ? path : path.slice(0, -1);
102+
}
103+
return path;
104+
}
105+
93106
/**
94107
* @param {string} path
95108
* @param {string} parent
96109
*/
97110
async function visit(path, parent) {
111+
path = normalizeTrailingSlash(path);
112+
98113
if (seen.has(path)) return;
99114
seen.add(path);
100115

0 commit comments

Comments
 (0)