treat foo.html and foo/index.html the same when generating manifest

This commit is contained in:
Richard Harris
2019-02-04 07:42:45 -05:00
parent 96b9d19715
commit 720cf8a859
4 changed files with 27 additions and 16 deletions

View File

@@ -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 {

View File

@@ -0,0 +1 @@
<h1>bar</h1>

View File

@@ -0,0 +1,2 @@
<h1>foo</h1>
<a href="dirs/bar">bar</a>

View File

@@ -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');
});
});