Skip to content

Commit

Permalink
fix(qwik-city): Correctly SSG routes even with trailingSlash: false (
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery authored Sep 8, 2023
1 parent 9f6aa65 commit 2f6411e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/qwik-city/adapters/shared/vite/post-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export async function postBuild(
) {
const ignorePathnames = new Set([basePathname + 'build/', basePathname + 'assets/']);

const staticPaths = new Set(userStaticPaths);
const staticPaths = new Set(userStaticPaths.map(normalizeTrailingSlash));
const notFounds: string[][] = [];

const loadItem = async (fsDir: string, fsName: string, pathname: string) => {
pathname = normalizeTrailingSlash(pathname);
if (ignorePathnames.has(pathname)) {
return;
}
Expand Down Expand Up @@ -62,6 +63,13 @@ export async function postBuild(
};
}

function normalizeTrailingSlash(pathname: string) {
if (!pathname.endsWith('/')) {
return pathname + '/';
}
return pathname;
}

function createNotFoundPathsModule(basePathname: string, notFounds: string[][], format: string) {
notFounds.sort((a, b) => {
if (a[0].length > b[0].length) {
Expand Down

0 comments on commit 2f6411e

Please sign in to comment.