Skip to content

Commit b6fa3dc

Browse files
committed
Add support for hashbangs (ignore).
1 parent 573b548 commit b6fa3dc

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-url",
3-
"version": "2.2.1",
3+
"version": "2.3.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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ test('hash string', function() {
235235
deepEqual( window.url( '#', 'http://domain.com#field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );
236236
});
237237

238+
test('hash bangs', function() {
239+
deepEqual( window.url( '?poo', 'http://domain.com/#!?' ), undefined );
240+
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( '?', 'http://domain.com/#!/?field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );
243+
deepEqual( window.url( '?', 'http://domain.com/#!?field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );
244+
deepEqual( window.url( '#', 'http://domain.com/#!/#field[0]=zero&field[1]=one&var=test' ), {'field': ['zero', 'one'], 'var': 'test'} );
245+
});
246+
238247
if (window.url('tld?')) {
239248
test('tld', function() {
240249
deepEqual( window.url( 'tld', 'www.example.ly' ), 'ly' );

url-tld.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

url.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"websanova",
77
"url"
88
],
9-
"version": "2.2.1",
9+
"version": "2.3.0",
1010
"author": {
1111
"name": "Websanova",
1212
"email": "rob@websanova.com",

url.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ window.url = (function() {
7777
}
7878
else {
7979

80+
// Ignore Hashbangs.
81+
if (tmp = url.match(/(.*?)\/#\!(.*)/)) {
82+
url = tmp[1] + tmp[2];
83+
}
84+
8085
// Hash.
8186
if (tmp = url.match(/(.*?)#(.*)/)) {
8287
_l.hash = tmp[2];

url.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)