diff --git a/src/core/create_manifest_data.ts b/src/core/create_manifest_data.ts index 41336c4..c3586b5 100644 --- a/src/core/create_manifest_data.ts +++ b/src/core/create_manifest_data.ts @@ -142,29 +142,26 @@ export default function create_manifest_data(cwd: string): ManifestData { } else if (item.is_page) { + const is_index = item.basename === 'index.html'; + const component = { name: get_slug(item.file), file: item.file, has_preload: has_preload(item.file) }; - const parts = stack.concat({ - component, - params - }); - components.push(component); - if (item.basename === 'index.html') { - pages.push({ - pattern: get_pattern(parent_segments, true), - parts - }); - } else { - pages.push({ - pattern: get_pattern(segments, true), - parts - }); - } + + const parts = (is_index && stack[stack.length - 1] === null) + ? stack.slice(0, -1).concat({ component, params }) + : stack.concat({ component, params }) + + const page = { + pattern: get_pattern(is_index ? parent_segments : segments, true), + parts + }; + + pages.push(page); } else { diff --git a/test/apps/basics/src/routes/dirs/bar/index.html b/test/apps/basics/src/routes/dirs/bar/index.html new file mode 100644 index 0000000..2cbd4ed --- /dev/null +++ b/test/apps/basics/src/routes/dirs/bar/index.html @@ -0,0 +1 @@ +

bar

\ No newline at end of file diff --git a/test/apps/basics/src/routes/dirs/foo/index.html b/test/apps/basics/src/routes/dirs/foo/index.html new file mode 100644 index 0000000..cd1373e --- /dev/null +++ b/test/apps/basics/src/routes/dirs/foo/index.html @@ -0,0 +1,2 @@ +

foo

+bar \ No newline at end of file diff --git a/test/apps/basics/test.ts b/test/apps/basics/test.ts index c2d28d3..1247bfc 100644 --- a/test/apps/basics/test.ts +++ b/test/apps/basics/test.ts @@ -264,4 +264,15 @@ describe('basics', function() { const html = String(await page.evaluate(() => document.body.innerHTML)); assert.equal(html.indexOf('%sapper'), -1); }); + + it('navigates between routes with empty parts', async () => { + await page.goto(`${base}/dirs/foo`); + await start(); + + assert.equal(await title(), 'foo'); + + await page.click('[href="dirs/bar"]'); + await wait(50); + assert.equal(await title(), 'bar'); + }); }); \ No newline at end of file