diff --git a/src/core/create_manifest_data.ts b/src/core/create_manifest_data.ts
index 327a8ba..4fce9b2 100644
--- a/src/core/create_manifest_data.ts
+++ b/src/core/create_manifest_data.ts
@@ -5,7 +5,7 @@ import { Page, PageComponent, ServerRoute, ManifestData } from '../interfaces';
import { posixify, reserved_words } from '../utils';
export default function create_manifest_data(cwd: string, extensions: string = '.svelte .html'): ManifestData {
-
+
const component_extensions = extensions.split(' ');
// TODO remove in a future version
@@ -335,7 +335,7 @@ function get_pattern(segments: Part[][], add_trailing_slash: boolean) {
const path = segments.map(segment => {
return segment.map(part => {
return part.dynamic
- ? part.qualifier || part.spread ? '(.+)' : '([^\\/]+?)'
+ ? part.qualifier || (part.spread ? '(.+)' : '([^\\/]+?)')
: encodeURI(part.content.normalize())
.replace(/\?/g, '%3F')
.replace(/#/g, '%23')
diff --git a/test/apps/basics/src/routes/[id([0-9]+)].svelte b/test/apps/basics/src/routes/[id([0-9]+)].svelte
new file mode 100644
index 0000000..38a9fca
--- /dev/null
+++ b/test/apps/basics/src/routes/[id([0-9]+)].svelte
@@ -0,0 +1,8 @@
+
+
+
Regexp page {$page.params.id}
+
+nested regexp route
diff --git a/test/apps/basics/src/routes/[slug].svelte b/test/apps/basics/src/routes/[slug].svelte
index 2f7d379..b39593a 100644
--- a/test/apps/basics/src/routes/[slug].svelte
+++ b/test/apps/basics/src/routes/[slug].svelte
@@ -3,4 +3,6 @@
const { page } = stores();
-{$page.params.slug.toUpperCase()}
\ No newline at end of file
+{$page.params.slug}
+
+regexp route
diff --git a/test/apps/basics/src/routes/regexp/[id([0-9]+)].svelte b/test/apps/basics/src/routes/regexp/[id([0-9]+)].svelte
new file mode 100644
index 0000000..6c2221d
--- /dev/null
+++ b/test/apps/basics/src/routes/regexp/[id([0-9]+)].svelte
@@ -0,0 +1,6 @@
+
+
+Nested regexp page {$page.params.id}
diff --git a/test/apps/basics/test.ts b/test/apps/basics/test.ts
index f545bb7..ba443fd 100644
--- a/test/apps/basics/test.ts
+++ b/test/apps/basics/test.ts
@@ -82,7 +82,7 @@ describe('basics', function() {
assert.equal(
await r.text('h1'),
- 'TEST-SLUG'
+ 'test-slug'
);
});
@@ -316,6 +316,22 @@ describe('basics', function() {
assert.equal(await r.text('h1'), 'B page');
});
+ it('find regexp routes', async () => {
+ await r.load('/qwe');
+ await r.sapper.start();
+
+ assert.equal(await r.text('h1'), 'qwe');
+
+ await r.page.click('[href="234"]');
+ await r.wait();
+
+ assert.equal(await r.text('h1'), 'Regexp page 234');
+
+ await r.page.click('[href="regexp/234"]');
+ await r.wait();
+ assert.equal(await r.text('h1'), 'Nested regexp page 234');
+ });
+
it('runs server route handlers before page handlers, if they match', async () => {
const json = await get(`${r.base}/middleware`, {
headers: {
diff --git a/test/unit/create_manifest_data/test.ts b/test/unit/create_manifest_data/test.ts
index 13f704b..6c3a98d 100644
--- a/test/unit/create_manifest_data/test.ts
+++ b/test/unit/create_manifest_data/test.ts
@@ -95,16 +95,15 @@ describe('manifest_data', () => {
]);
});
- // this test broken
- // it('allows regex qualifiers', () => {
- // const { pages } = create_manifest_data(path.join(__dirname, 'samples/qualifiers'));
- //
- // assert.deepEqual(pages.map(p => p.pattern), [
- // /^\/([0-9-a-z]{3,})\/?$/,
- // /^\/([a-z]{2})\/?$/,
- // /^\/([^\/]+?)\/?$/
- // ]);
- // });
+ it('allows regex qualifiers', () => {
+ const { pages } = create_manifest_data(path.join(__dirname, 'samples/qualifiers'));
+
+ assert.deepEqual(pages.map(p => p.pattern), [
+ /^\/([0-9-a-z]{3,})\/?$/,
+ /^\/([a-z]{2})\/?$/,
+ /^\/([^\/]+?)\/?$/
+ ]);
+ });
it('sorts routes correctly', () => {
const { pages } = create_manifest_data(path.join(__dirname, 'samples/sorting'));