diff --git a/lib/path.js b/lib/path.js index 2c68df1..08d5aac 100644 --- a/lib/path.js +++ b/lib/path.js @@ -36,10 +36,6 @@ var _class = function (_UrlPart) { key: 'sanitize_replacements', get: function get() { return [ - // add trailing slash if path is empty - { substring: /^$/, replacement: '\/' }, - // add trailing slash if path does not end with asterisk or trailing slash - { substring: /[^/*]$/, replacement: '$&\/' }, // assume trailing slash at the end of path is optional { substring: /\/$/, replacement: '\\/?' }, { substring: /\/\*$/, replacement: '((\/?)|\/*)' }, // allow letters, numbers, hyphens, dots, slashes and underscores diff --git a/src/path.js b/src/path.js index bd114d3..ba13988 100644 --- a/src/path.js +++ b/src/path.js @@ -9,10 +9,6 @@ export default class extends UrlPart { get sanitize_replacements () { return [ - // add trailing slash if path is empty - {substring: /^$/, replacement: '\/'}, - // add trailing slash if path does not end with asterisk or trailing slash - {substring: /[^/*]$/, replacement: '$&\/'}, // assume trailing slash at the end of path is optional {substring: /\/$/, replacement: '\\/?'}, {substring: /\/\*$/, replacement: '((\/?)|\/*)'}, diff --git a/test/path.spec.js b/test/path.spec.js index 6cace39..0f4144e 100644 --- a/test/path.spec.js +++ b/test/path.spec.js @@ -72,12 +72,6 @@ describe('Path', function() { expect(path.test('bbb.ccc', path.sanitize('*/*.ccc'))).toBe(false); }); - it('should add trailing slash if missing', function () { - expect(path.test('/', path.sanitize(''))).toBe(true); - expect(path.test('aaa/', path.sanitize('aaa'))).toBe(true); - expect(path.test('aaa/bbb/', path.sanitize('aaa/bbb'))).toBe(true); - }); - it('should assume trailing `/` is optional', function() { expect(path.test('', path.sanitize('/'))).toBe(true); expect(path.test('aaa', path.sanitize('aaa/'))).toBe(true); diff --git a/test/real-life-examples.spec.js b/test/real-life-examples.spec.js index 1fed9e1..6cc2704 100644 --- a/test/real-life-examples.spec.js +++ b/test/real-life-examples.spec.js @@ -90,11 +90,4 @@ describe('Real life examples', function() { expect(my_match.test('http://localhost:3000/aaa/bbb')).toBe(true); }); - it('should handle missing trailing slash', function () { - const my_match = new UrlMatch('*://*/ccc'); - expect(my_match.test('http://aaa.bbb/ccc')).toBe(true); - expect(my_match.test('http://aaa.bbb/ccc/')).toBe(true); - expect(my_match.test('http://aaa.bbb/ccc/ddd')).toBe(false); - }); - });