mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
treat foo.html and foo/index.html the same when generating manifest
This commit is contained in:
@@ -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 {
|
||||
|
||||
1
test/apps/basics/src/routes/dirs/bar/index.html
Normal file
1
test/apps/basics/src/routes/dirs/bar/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>bar</h1>
|
||||
2
test/apps/basics/src/routes/dirs/foo/index.html
Normal file
2
test/apps/basics/src/routes/dirs/foo/index.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>foo</h1>
|
||||
<a href="dirs/bar">bar</a>
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user