Skip to content

Commit 568a75d

Browse files
committed
Add backslash to ignore chars to avoid backtrack
1 parent 42f4445 commit 568a75d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var PATH_REGEXP = new RegExp([
2424
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
2525
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
2626
// "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
27-
'([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))'
27+
'([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
2828
].join('|'), 'g')
2929

3030
/**

test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,25 @@ var TESTS: Test[] = [
19101910
[{ foo: 'a', bar: 'b' }, '/a/b']
19111911
]
19121912
],
1913+
[
1914+
'/:foo(test\\)/bar',
1915+
null,
1916+
[
1917+
{
1918+
name: 'foo',
1919+
prefix: '/',
1920+
delimiter: '/',
1921+
optional: false,
1922+
repeat: false,
1923+
partial: true,
1924+
asterisk: false,
1925+
pattern: '[^\\/]+?'
1926+
},
1927+
'(test)/bar'
1928+
],
1929+
[],
1930+
[]
1931+
],
19131932
[
19141933
'/:remote([\\w-.]+)/:user([\\w-]+)',
19151934
null,

0 commit comments

Comments
 (0)