Comparing version 0.0.2 to 0.0.3
33
index.js
@@ -14,7 +14,15 @@ 'use strict'; | ||
var parse = 'undefined' !== typeof document ? function parse(url, qs) { | ||
var a = document.createElement('a') | ||
var div = document.createElement('div') | ||
, data = {} | ||
, key; | ||
, key | ||
, a; | ||
a.href = url; | ||
// | ||
// Uses an innerHTML property to obtain an absolute URL for older browser | ||
// support like IE6. | ||
// | ||
// @see http://grack.com/blog/2009/11/17/absolutizing-url-in-javascript/ | ||
// | ||
div.innerHTML = '<a href="' + url + '"/>'; | ||
a = div.firstChild; | ||
@@ -33,2 +41,10 @@ // | ||
// | ||
// encodeURI and decodeURI are needed to normalize URL between IE and non-IE, | ||
// since IE doesn't encode the href property value and return it | ||
// | ||
// @see http://jsfiddle.net/Yq9M8/1/ | ||
// | ||
data.href = encodeURI(decodeURI(data.href)); | ||
// | ||
// If we don't obtain a port number (e.g. when using zombie) then try | ||
@@ -52,5 +68,9 @@ // and guess at a value from the 'href' value. | ||
// IE quirk: The `protocol` is parsed as ":" when a protocol agnostic URL | ||
// is used. In this case we extract the value from the `href` value. | ||
// is used. In this case we extract the value from the `href` value. In | ||
// addition to that, it's possible in IE11 that the protocol is an string for | ||
// relative URL's. | ||
// | ||
if (':' === data.protocol) { | ||
// @see https://github.com/primus/primus/issues/242 | ||
// | ||
if (!data.protocol || ':' === data.protocol) { | ||
data.protocol = data.href.substr(0, data.href.indexOf(':') + 1); | ||
@@ -76,5 +96,6 @@ } | ||
if (qs && 'string' === typeof data.query) { | ||
data.query = querystring(data.query); | ||
data.query = querystring(data.query || data.search); | ||
} | ||
data.query = data.query || data.search; | ||
return data; | ||
@@ -81,0 +102,0 @@ } : require('url').parse; |
{ | ||
"name": "url-parse", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Parse URL in node using the URL module and in the browser using the DOM", | ||
@@ -30,2 +30,16 @@ "main": "index.js", | ||
}, | ||
"testling": { | ||
"files": "test.js", | ||
"harness": "mocha-bdd", | ||
"browsers": [ | ||
"ie/6..latest", | ||
"chrome/22..latest", | ||
"firefox/16..latest", | ||
"safari/latest", | ||
"opera/11.0..latest", | ||
"iphone/6", | ||
"ipad/6", | ||
"android-browser/latest" | ||
] | ||
}, | ||
"repository": { | ||
@@ -32,0 +46,0 @@ "type": "git", |
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
9203
185