Checking the current_branch[i] route match against the current request's route match.

current_branch[i].match.slice(1, i+2) compared to match.slice(1, i+2)

Fixes https://github.com/sveltejs/sapper/issues/688
This commit is contained in:
Brian Takita
2019-05-13 02:38:15 -04:00
parent 7aa3e90f87
commit 5460896228
6 changed files with 74 additions and 11 deletions

View File

@@ -16,4 +16,5 @@
</script>
<span>z: {$page.params.z} {count}</span>
<a href="foo/bar/qux">click me</a>
<a href="foo/bar/qux">goto foo/bar/qux</a>
<a href="foo/abc/def">goto foo/abc/def</a>

View File

@@ -23,7 +23,8 @@ describe('layout', function() {
assert.deepEqual(text1.split('\n').map(str => str.trim()).filter(Boolean), [
'y: bar 1',
'z: baz 1',
'click me',
'goto foo/bar/qux',
'goto foo/abc/def',
'child segment: baz'
]);
@@ -32,7 +33,8 @@ describe('layout', function() {
assert.deepEqual(text2.split('\n').map(str => str.trim()).filter(Boolean), [
'y: bar 1',
'z: baz 1',
'click me',
'goto foo/bar/qux',
'goto foo/abc/def',
'child segment: baz'
]);
@@ -43,9 +45,22 @@ describe('layout', function() {
assert.deepEqual(text3.split('\n').map(str => str.trim()).filter(Boolean), [
'y: bar 1',
'z: qux 2',
'click me',
'goto foo/bar/qux',
'goto foo/abc/def',
'child segment: qux'
]);
await r.page.click('[href="foo/abc/def"]');
await r.wait();
const text4 = await r.text('#sapper');
assert.deepEqual(text4.split('\n').map(str => str.trim()).filter(Boolean), [
'y: abc 2',
'z: def 3',
'goto foo/bar/qux',
'goto foo/abc/def',
'child segment: def'
]);
});
it('survives the tests with no server errors', () => {