Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

build-url

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-url - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

13

dist/build-url.js
/**
* 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) {

4

dist/build-url.min.js
/**
* 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) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc