Skip to content

Commit

Permalink
Fix matching empty string with end: false
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Apr 22, 2018
1 parent 761c721 commit bb72b60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -305,7 +305,7 @@ function tokensToRegExp (tokens, keys, options) {
var delimiters = options.delimiters || DEFAULT_DELIMITERS
var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')
var route = ''
var isEndDelimited = false
var isEndDelimited = tokens.length === 0

// Iterate over the tokens and create our regexp string.
for (var i = 0; i < tokens.length; i++) {
Expand Down
17 changes: 17 additions & 0 deletions test.ts
Expand Up @@ -237,6 +237,23 @@ var TESTS: Test[] = [
[{ test: 'abc' }, '/abc/']
]
],
[
'',
{
end: false
},
[],
[
['', ['']],
['/', ['/']],
['route', ['']],
['/route', ['']],
['/route/', ['']]
],
[
[null, '']
]
],

/**
* Combine modes.
Expand Down

0 comments on commit bb72b60

Please sign in to comment.