Skip to content

Commit 28d2934

Browse files
authored
Fix matching empty string with end: false (#149)
1 parent 761c721 commit 28d2934

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function tokensToRegExp (tokens, keys, options) {
305305
var delimiters = options.delimiters || DEFAULT_DELIMITERS
306306
var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')
307307
var route = ''
308-
var isEndDelimited = false
308+
var isEndDelimited = tokens.length === 0
309309

310310
// Iterate over the tokens and create our regexp string.
311311
for (var i = 0; i < tokens.length; i++) {

test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,23 @@ var TESTS: Test[] = [
237237
[{ test: 'abc' }, '/abc/']
238238
]
239239
],
240+
[
241+
'',
242+
{
243+
end: false
244+
},
245+
[],
246+
[
247+
['', ['']],
248+
['/', ['/']],
249+
['route', ['']],
250+
['/route', ['']],
251+
['/route/', ['']]
252+
],
253+
[
254+
[null, '']
255+
]
256+
],
240257

241258
/**
242259
* Combine modes.

0 commit comments

Comments
 (0)