Skip to content

Commit 9e6c6f1

Browse files
committed
Escape back-slashes as part of escapeString fn
1 parent d933b45 commit 9e6c6f1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function tokensToFunction (tokens) {
223223
* @return {string}
224224
*/
225225
function escapeString (str) {
226-
return str.replace(/([.+*?=^!:${}()[\]|\/])/g, '\\$1')
226+
return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
227227
}
228228

229229
/**

test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,28 @@ var TESTS: Test[] = [
14971497
[{ '0': '123' }, '/123']
14981498
]
14991499
],
1500+
[
1501+
'/route\\(\\\\(\\d+\\\\)\\)',
1502+
null,
1503+
[
1504+
'/route(\\',
1505+
{
1506+
name: 0,
1507+
prefix: '',
1508+
delimiter: '/',
1509+
optional: false,
1510+
repeat: false,
1511+
partial: false,
1512+
asterisk: false,
1513+
pattern: '\\d+\\\\'
1514+
},
1515+
')'
1516+
],
1517+
[
1518+
['/route(\\123\\)', ['/route(\\123\\)', '123\\']]
1519+
],
1520+
[]
1521+
],
15001522

15011523
/**
15021524
* Regexps.

0 commit comments

Comments
 (0)