Comparing version 1.0.6 to 1.0.7
/** | ||
* build-url - A small library that builds a URL given it's components | ||
* @version v1.0.1 | ||
* @version v1.0.6 | ||
* @link https://github.com/steverydz/build-url#readme | ||
@@ -16,4 +16,13 @@ * @license MIT | ||
var key; | ||
var builtUrl = url; | ||
var builtUrl; | ||
if (url === null) { | ||
builtUrl = ''; | ||
} else if (typeof(url) === 'object') { | ||
builtUrl = ''; | ||
options = url; | ||
} else { | ||
builtUrl = url; | ||
} | ||
if (options) { | ||
@@ -20,0 +29,0 @@ if (options.path) { |
/** | ||
* build-url - A small library that builds a URL given it's components | ||
* @version v1.0.1 | ||
* @version v1.0.6 | ||
* @link https://github.com/steverydz/build-url#readme | ||
* @license MIT | ||
*/ | ||
(function(){"use strict";var r=this,e=r.buildUrl,t=function(r,e){var t,u=[],o=r;if(e){if(e.path&&(o+="/"+e.path),e.queryParams){for(t in e.queryParams)e.queryParams.hasOwnProperty(t)&&u.push(t+"="+e.queryParams[t]);o+="?"+u.join("&")}e.hash&&(o+="#"+e.hash)}return o};t.noConflict=function(){return r.buildUrl=e,t},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=t),exports.buildUrl=t):r.buildUrl=t}).call(this); | ||
(function(){"use strict";var r=this,e=r.buildUrl,t=function(r,e){var t,u,o=[];if(null===r?u="":"object"==typeof r?(u="",e=r):u=r,e){if(e.path&&(u+="/"+e.path),e.queryParams){for(t in e.queryParams)e.queryParams.hasOwnProperty(t)&&o.push(t+"="+e.queryParams[t]);u+="?"+o.join("&")}e.hash&&(u+="#"+e.hash)}return u};t.noConflict=function(){return r.buildUrl=e,t},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=t),exports.buildUrl=t):r.buildUrl=t}).call(this); |
{ | ||
"name": "build-url", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A small library that builds a URL given it's components", | ||
@@ -37,8 +37,8 @@ "main": "./dist/build-url.js", | ||
"devDependencies": { | ||
"gulp": "3.9.0", | ||
"gulp": "3.9.1", | ||
"gulp-header": "1.7.1", | ||
"gulp-rename": "1.2.2", | ||
"gulp-uglify": "1.5.1", | ||
"gulp-uglify": "1.5.3", | ||
"jasmine": "2.4.1" | ||
} | ||
} |
@@ -83,2 +83,98 @@ describe('buildUrl', function () { | ||
}); | ||
it('should return only the query string when URL parameter is an empty string', function () { | ||
expect(buildUrl('', { | ||
queryParams: { | ||
foo: 'bar', | ||
bar: 'baz' | ||
} | ||
})).toEqual('?foo=bar&bar=baz'); | ||
}); | ||
it('should return only the query string when URL parameter is null', function () { | ||
expect(buildUrl(null, { | ||
queryParams: { | ||
foo: 'bar', | ||
bar: 'baz' | ||
} | ||
})).toEqual('?foo=bar&bar=baz'); | ||
}); | ||
it('should return only the query string when URL parameter is not present', function () { | ||
expect(buildUrl({ | ||
queryParams: { | ||
foo: 'bar', | ||
bar: 'baz' | ||
} | ||
})).toEqual('?foo=bar&bar=baz'); | ||
}); | ||
it('should return only the hash when URL parameter is an empty string', function () { | ||
expect(buildUrl('', { | ||
hash: 'about' | ||
})).toEqual('#about'); | ||
}); | ||
it('should return only the hash when URL parameter is null', function () { | ||
expect(buildUrl(null, { | ||
hash: 'about' | ||
})).toEqual('#about'); | ||
}); | ||
it('should return only the has when URL parameter is not present', function () { | ||
expect(buildUrl({ | ||
hash: 'about' | ||
})).toEqual('#about'); | ||
}); | ||
it('should return only the path when URL parameter is an empty string', function () { | ||
expect(buildUrl('', { | ||
path: 'contact' | ||
})).toEqual('/contact'); | ||
}); | ||
it('should return only the path when URL parameter is null', function () { | ||
expect(buildUrl(null, { | ||
path: 'contact' | ||
})).toEqual('/contact'); | ||
}); | ||
it('should return only the path when URL parameter is not present', function () { | ||
expect(buildUrl({ | ||
path: 'contact' | ||
})).toEqual('/contact'); | ||
}); | ||
it('should return only formatted options when URL parameter is an empty string', function () { | ||
expect(buildUrl('', { | ||
path: 'contact', | ||
hash: 'about', | ||
queryParams: { | ||
foo: 'bar', | ||
bar: 'baz' | ||
} | ||
})).toEqual('/contact?foo=bar&bar=baz#about'); | ||
}); | ||
it('should return only formatted options when URL parameter is null', function () { | ||
expect(buildUrl(null, { | ||
path: 'contact', | ||
hash: 'about', | ||
queryParams: { | ||
foo: 'bar', | ||
bar: 'baz' | ||
} | ||
})).toEqual('/contact?foo=bar&bar=baz#about'); | ||
}); | ||
it('should return only formatted options when URL parameter is not present', function () { | ||
expect(buildUrl({ | ||
path: 'contact', | ||
hash: 'about', | ||
queryParams: { | ||
foo: 'bar', | ||
bar: 'baz' | ||
} | ||
})).toEqual('/contact?foo=bar&bar=baz#about'); | ||
}); | ||
}); |
@@ -10,4 +10,13 @@ ;(function () { | ||
var key; | ||
var builtUrl = url; | ||
var builtUrl; | ||
if (url === null) { | ||
builtUrl = ''; | ||
} else if (typeof(url) === 'object') { | ||
builtUrl = ''; | ||
options = url; | ||
} else { | ||
builtUrl = url; | ||
} | ||
if (options) { | ||
@@ -14,0 +23,0 @@ if (options.path) { |
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
13943
347