Skip to content

Commit 6d1209c

Browse files
committedApr 22, 2017
Fix to not remove trailing slash on paths.
1 parent daeed5e commit 6d1209c

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-url",
3-
"version": "2.4.1",
3+
"version": "2.5.0",
44
"description": "A simple, lightweight url parser for JavaScript (~1.7 Kb minified, ~0.7Kb gzipped).",
55
"main": "url.js",
66
"repository": {

‎tests.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,25 @@ test('protocol', function() {
144144
test('path', function() {
145145
deepEqual( window.url( 'path', url ), '/path/index.html' );
146146
deepEqual( window.url( 'path', 'http://www.domain.com/first/second' ), '/first/second' );
147-
deepEqual( window.url( 'path', 'http://www.domain.com/first/second/' ), '/first/second' );
147+
deepEqual( window.url( 'path', 'http://www.domain.com/first/second/' ), '/first/second/' );
148148
deepEqual( window.url( 'path', 'http://www.domain.com:8080/first/second' ), '/first/second' );
149-
deepEqual( window.url( 'path', 'http://www.domain.com:8080/first/second/' ), '/first/second' );
149+
deepEqual( window.url( 'path', 'http://www.domain.com:8080/first/second/' ), '/first/second/' );
150150
deepEqual( window.url( 'path', 'http://www.domain.com/first/second?test=foo' ), '/first/second' );
151-
deepEqual( window.url( 'path', 'http://www.domain.com/first/second/?test=foo' ), '/first/second' );
151+
deepEqual( window.url( 'path', 'http://www.domain.com/first/second/?test=foo' ), '/first/second/' );
152152
deepEqual( window.url( 'path', 'http://www.domain.com/path#anchor' ), '/path' );
153-
deepEqual( window.url( 'path', 'http://www.domain.com/path/#anchor' ), '/path' );
153+
deepEqual( window.url( 'path', 'http://www.domain.com/path/#anchor' ), '/path/' );
154154
deepEqual( window.url( 'path', 'http://www.domain.com' ), '' );
155-
deepEqual( window.url( 'path', 'http://www.domain.com/' ), '' );
155+
deepEqual( window.url( 'path', 'http://www.domain.com/' ), '/' );
156156
deepEqual( window.url( 'path', 'http://www.domain.com#anchor' ), '' );
157-
deepEqual( window.url( 'path', 'http://www.domain.com/#anchor' ), '' );
157+
deepEqual( window.url( 'path', 'http://www.domain.com/#anchor' ), '/' );
158158
deepEqual( window.url( 'path', 'http://www.domain.com?test=foo' ), '' );
159-
deepEqual( window.url( 'path', 'http://www.domain.com/?test=foo' ), '' );
159+
deepEqual( window.url( 'path', 'http://www.domain.com/?test=foo' ), '/' );
160160
deepEqual( window.url( 'path', 'http://www.domain.com:80' ), '' );
161-
deepEqual( window.url( 'path', 'http://www.domain.com:80/' ), '' );
161+
deepEqual( window.url( 'path', 'http://www.domain.com:80/' ), '/' );
162162
deepEqual( window.url( 'path', 'http://www.domain.com:80#anchor' ), '' );
163-
deepEqual( window.url( 'path', 'http://www.domain.com:80/#anchor' ), '' );
163+
deepEqual( window.url( 'path', 'http://www.domain.com:80/#anchor' ), '/' );
164164
deepEqual( window.url( 'path', 'http://www.domain.com:80?test=foo' ), '' );
165-
deepEqual( window.url( 'path', 'http://www.domain.com:80/?test=foo' ), '' );
165+
deepEqual( window.url( 'path', 'http://www.domain.com:80/?test=foo' ), '/' );
166166
});
167167

168168
test('file', function() {
@@ -186,7 +186,8 @@ test('url parts', function() {
186186
deepEqual( window.url( '1', 'http://www.domain.com/first/second' ), 'first' );
187187
deepEqual( window.url( '1', 'http://www.domain.com/first/second/' ), 'first' );
188188
deepEqual( window.url( '-1', 'http://www.domain.com/first/second?test=foo' ), 'second' );
189-
deepEqual( window.url( '-1', 'http://www.domain.com/first/second/?test=foo' ), 'second' );
189+
deepEqual( window.url( '-1', 'http://www.domain.com/first/second/?test=foo' ), '' );
190+
deepEqual( window.url( '-2', 'http://www.domain.com/first/second/?test=foo' ), 'second' );
190191
});
191192

192193
test('query string', function() {
@@ -238,7 +239,8 @@ test('hash string', function() {
238239
test('hash bangs', function() {
239240
deepEqual( window.url( '?poo', 'http://domain.com/#!?' ), undefined );
240241
deepEqual( window.url( '?poo', 'http://domain.com/#!/' ), undefined );
241-
deepEqual( window.url( '-1', 'http://www.domain.com/#!/first/second/?test=foo' ), 'second' );
242+
deepEqual( window.url( '-1', 'http://www.domain.com/#!/first/second/?test=foo' ), '' );
243+
deepEqual( window.url( '-2', 'http://www.domain.com/#!/first/second/?test=foo' ), 'second' );
242244
deepEqual( window.url( '?', 'http://domain.com/#!/?field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );
243245
deepEqual( window.url( '?', 'http://domain.com/#!?field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );
244246
deepEqual( window.url( '#', 'http://domain.com/#!/#field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );

‎url-tld.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎url.jquery.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"websanova",
77
"url"
88
],
9-
"version": "2.4.1",
9+
"version": "2.5.0",
1010
"author": {
1111
"name": "Websanova",
1212
"email": "rob@websanova.com",

‎url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
}
115115

116116
// Clean up path.
117-
_l.path = (_l.path || '').replace(/^([^\/])/, '/$1').replace(/\/$/, '');
117+
_l.path = (_l.path || '').replace(/^([^\/])/, '/$1');
118118

119119
// Return path parts.
120120
if (arg.match(/^[\-0-9]+$/)) { arg = arg.replace(/^([^\/])/, '/$1'); }

‎url.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.