Comparing version 1.0.3 to 1.0.4
10
index.js
@@ -113,3 +113,3 @@ 'use strict'; | ||
// | ||
if (parser && url.query) url.query = parser(url.query); | ||
if (parser) url.query = parser(url.query); | ||
@@ -215,9 +215,5 @@ // | ||
if (url.query) { | ||
if ('object' === typeof url.query) query = stringify(url.query); | ||
else query = url.query; | ||
query = 'object' === typeof url.query ? stringify(url.query) : url.query; | ||
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query; | ||
result += (query.charAt(0) === '?' ? '' : '?') + query; | ||
} | ||
if (url.hash) result += url.hash; | ||
@@ -224,0 +220,0 @@ |
{ | ||
"name": "url-parse", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Small footprint URL parser that works seamlessly across Node.js and browser environments", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"istanbul": "0.3.x", | ||
"mocha": "2.2.x", | ||
"mocha": "2.3.x", | ||
"mochify": "2.13.x", | ||
@@ -36,0 +36,0 @@ "pre-commit": "1.1.x", |
# url-parse | ||
[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/url-parse.svg?style=flat-square)](http://browsenpm.org/package/url-parse)[![Build Status](http://img.shields.io/travis/unshiftio/url-parse/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/url-parse)[![Dependencies](https://img.shields.io/david/unshiftio/url-parse.svg?style=flat-square)](https://david-dm.org/unshiftio/url-parse)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/url-parse/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/url-parse?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift) | ||
The `url-parse` method exposes two different API interfaces. The `url` interface | ||
that you know from Node.js and the new `URL` interface that is available in the | ||
latest browsers. | ||
The `url-parse` method exposes two different API interfaces. The | ||
[`url`](https://nodejs.org/api/url.html) interface that you know from Node.js | ||
and the new [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) | ||
interface that is available in the latest browsers. | ||
@@ -8,0 +9,0 @@ Since `0.1` we've moved away from using the DOM's `<a>` element for URL parsing |
25
test.js
@@ -19,3 +19,3 @@ describe('url-parse', function () { | ||
it('parsers the query string', function () { | ||
it('parses the query string into an object', function () { | ||
var url = 'http://google.com/?foo=bar' | ||
@@ -26,5 +26,11 @@ , data = parse(url, true); | ||
assume(data.query.foo).equals('bar'); | ||
url = 'http://google.com/'; | ||
data = parse(url, true); | ||
assume(data.query).is.a('object'); | ||
assume(data.query).is.empty(); | ||
}); | ||
it('does not add question mark to href if query string empty', function () { | ||
it('does not add question mark to href if query string is empty', function () { | ||
var url = 'http://google.com/' | ||
@@ -60,4 +66,15 @@ , data = parse(url, true); | ||
it('is blob: location aware', function () { | ||
var blob = {"hash":"","search":"","pathname":"https%3A//gist.github.com/3f272586-6dac-4e29-92d0-f674f2dde618","port":"","hostname":"","host":"","protocol":"blob:","origin":"https://gist.github.com","href":"blob:https%3A//gist.github.com/3f272586-6dac-4e29-92d0-f674f2dde618"} | ||
, url = '/unshiftio/url-parse' | ||
var blob = { | ||
'href': 'blob:https%3A//gist.github.com/3f272586-6dac-4e29-92d0-f674f2dde618', | ||
'pathname': 'https%3A//gist.github.com/3f272586-6dac-4e29-92d0-f674f2dde618', | ||
'origin': 'https://gist.github.com', | ||
'protocol': 'blob:', | ||
'hostname': '', | ||
'search': '', | ||
'hash': '', | ||
'host': '', | ||
'port': '' | ||
}; | ||
var url = '/unshiftio/url-parse' | ||
, data = parse(url, blob); | ||
@@ -64,0 +81,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31341
616
121