Skip to content

Commit

Permalink
feat: allow optional trailing slash for '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
troch committed Sep 1, 2015
1 parent e86aca6 commit 570a0c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let tokenise = (str, tokens = []) => {
}

let optTrailingSlash = (source, trailingSlash) => {
if (!trailingSlash || source === '\\/') return source
if (!trailingSlash) return source
return source.replace(/\\\/$/, '') + '(?:\\/)?'
}

Expand Down
5 changes: 5 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,10 @@ describe('Path', function () {
should.not.exist(path.match('/my-path'));
path.match('/my-path', true).should.eql({});
path.match('/my-path', 1).should.eql({});

path = new Path('/');
should.not.exist(path.match(''));
path.match('/', true).should.eql({});
path.match('', 1).should.eql({});
});
});

0 comments on commit 570a0c4

Please sign in to comment.