Skip to content

Commit

Permalink
fix: append trailing slash in manifest (#1507)
Browse files Browse the repository at this point in the history
* fix: normalize trailing slash in prerender (#1486)

* this is a camelCase-free zone, except for public APIs

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
pzerelles and Rich-Harris authored May 29, 2021
1 parent b0e6296 commit 1bb44ca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/kit/src/core/adapt/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,26 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
}
});

/**
* @param {string} path
*/
function normalize(path) {
if (config.kit.trailingSlash === 'always') {
return path.endsWith('/') ? path : `${path}/`;
} else if (config.kit.trailingSlash === 'never') {
return !path.endsWith('/') || path === '/' ? path : path.slice(0, -1);
}

return path;
}

/**
* @param {string} path
* @param {string} parent
*/
async function visit(path, parent) {
path = normalize(path);

if (seen.has(path)) return;
seen.add(path);

Expand Down

0 comments on commit 1bb44ca

Please sign in to comment.