Comparing version 1.4.0 to 1.5.0
11
index.js
@@ -30,9 +30,12 @@ 'use strict' | ||
if (!result) { | ||
// Cache result. | ||
result = new URL(path, base) | ||
// Parse url and cache result. | ||
var parsed = new URL(path, base) | ||
result = {} | ||
// Make each part default to empty string for consistency. | ||
for (var i = parts.length, part; i--;) { | ||
for (var i = parts.length, part, data; i--;) { | ||
part = parts[i] | ||
result[part] = result[part] || '' | ||
data = parsed[part] | ||
if (data == null) data = '' | ||
result[part] = data | ||
} | ||
@@ -39,0 +42,0 @@ |
{ | ||
"name": "mini-url", | ||
"description": "Lightweight isomorphic url parser.", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"author": "Dylan Piercey <pierceydylan@gmail.com>", | ||
@@ -6,0 +6,0 @@ "browser": { |
@@ -44,3 +44,3 @@ 'use strict' | ||
// Patch for browsers automatically adding default ports. | ||
if (this.port) { | ||
if (this.port !== '') { | ||
var href = this.href | ||
@@ -47,0 +47,0 @@ var hostname = this.hostname |
@@ -17,3 +17,3 @@ 'use strict' | ||
part = parts[i] | ||
this[part] = parsed[part] || '' | ||
this[part] = parsed[part] | ||
} | ||
@@ -20,0 +20,0 @@ } |
@@ -81,3 +81,6 @@ 'use strict' | ||
for (var key in expected) { | ||
assert.equal(actual[key], decodeURIComponent(expected[key]), key + ' should match') | ||
assert.equal( | ||
actual[key] || '', | ||
decodeURIComponent(expected[key]) | ||
) | ||
} | ||
@@ -84,0 +87,0 @@ }) |
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
10237
270