Comparing version 5.0.2 to 6.0.0
@@ -1,1 +0,101 @@ | ||
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e);var n=function(t,e,r){"/"===e[e.length-1]&&(e=e.slice(0,-1));var n=String(t).trim();return r&&(n=n.toLowerCase()),0===n.indexOf("/")?e+=n:e+="/".concat(n),e};var o=function(t,e){var r="#".concat(String(t).trim());return e?r.toLowerCase():r};var u=function(t,e,r){var n=[];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&void 0!==t[o]){var u=void 0;if(r&&Array.isArray(t[o])&&t[o].length)for(var a=0;a<t[o].length;a++)u=t[o][a]||"",n.push("".concat(o,"=").concat(encodeURIComponent(String(u).trim())));else u=e?t[o].toLowerCase()||"":t[o]||"",n.push("".concat(o,"=").concat(encodeURIComponent(String(u).trim())))}return"?".concat(n.join("&"))};function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}e.default=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return null===t?e="":"object"===a(t)?(e="",r=t):e=t,r.path&&(e=n(r.path,e,r.lowerCase)),r.queryParams&&(e+=u(r.queryParams,r.lowerCase,r.disableCSV)),r.hash&&(e+=o(r.hash,r.lowerCase)),e}}]); | ||
/** | ||
* build-url - A small library that builds a URL given its components | ||
* @version v3.0.0 | ||
* @link https://github.com/steverydz/build-url#readme | ||
* @license MIT | ||
*/ | ||
;(function () { | ||
'use strict'; | ||
var root = this; | ||
var previousBuildUrl = root.buildUrl; | ||
var encodedParam = function (param) { | ||
return param === null ? '' : encodeURIComponent(String(param).trim()); | ||
}; | ||
var buildUrl = function (url, options) { | ||
var queryString = []; | ||
var key; | ||
var builtUrl; | ||
var caseChange; | ||
if (options && options.lowerCase) { | ||
caseChange = !!options.lowerCase; | ||
} else { | ||
caseChange = false; | ||
} | ||
if (url === null) { | ||
builtUrl = ''; | ||
} else if (typeof(url) === 'object') { | ||
builtUrl = ''; | ||
options = url; | ||
} else { | ||
builtUrl = url; | ||
} | ||
if (options) { | ||
if (options.path) { | ||
if(builtUrl && builtUrl[builtUrl.length - 1] === '/') { | ||
builtUrl = builtUrl.slice(0, -1); | ||
} | ||
var localVar = String(options.path).trim(); | ||
if (caseChange) { | ||
localVar = localVar.toLowerCase(); | ||
} | ||
if (localVar.indexOf('/') === 0) { | ||
builtUrl += localVar; | ||
} else { | ||
builtUrl += '/' + localVar; | ||
} | ||
} | ||
if (options.queryParams) { | ||
for (key in options.queryParams) { | ||
if (options.queryParams.hasOwnProperty(key) && options.queryParams[key] !== void 0) { | ||
var param; | ||
if (options.disableCSV && Array.isArray(options.queryParams[key]) && options.queryParams[key].length) { | ||
for(var i = 0; i < options.queryParams[key].length; i++) { | ||
param = options.queryParams[key][i]; | ||
queryString.push(key + '=' + encodedParam(param)); | ||
} | ||
} else { | ||
if (caseChange) { | ||
param = options.queryParams[key].toLowerCase(); | ||
} | ||
else { | ||
param = options.queryParams[key]; | ||
} | ||
queryString.push(key + '=' + encodedParam(param)); | ||
} | ||
} | ||
} | ||
builtUrl += '?' + queryString.join('&'); | ||
} | ||
if (options.hash) { | ||
if(caseChange) | ||
builtUrl += '#' + String(options.hash).trim().toLowerCase(); | ||
else | ||
builtUrl += '#' + String(options.hash).trim(); | ||
} | ||
} | ||
return builtUrl; | ||
}; | ||
buildUrl.noConflict = function () { | ||
root.buildUrl = previousBuildUrl; | ||
return buildUrl; | ||
}; | ||
if (typeof(exports) !== 'undefined') { | ||
if (typeof(module) !== 'undefined' && module.exports) { | ||
exports = module.exports = buildUrl; | ||
} | ||
exports.buildUrl = buildUrl; | ||
} else { | ||
root.buildUrl = buildUrl; | ||
} | ||
}).call(this); |
{ | ||
"name": "build-url", | ||
"version": "5.0.2", | ||
"version": "6.0.0", | ||
"description": "A small library that builds a URL given its components", | ||
"main": "./src/build-url.js", | ||
"main": "./dist/build-url.js", | ||
"types": "./build-url.d.ts", | ||
"scripts": { | ||
"build": "webpack", | ||
"lint-js": "eslint src/**/*.js", | ||
"prepublishOnly": "webpack", | ||
"test": "jest", | ||
"test-watch": "jest --watch" | ||
"test": "./node_modules/jasmine/bin/jasmine.js" | ||
}, | ||
@@ -41,13 +38,9 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "7.11.4", | ||
"@babel/preset-env": "7.11.0", | ||
"babel-loader": "8.1.0", | ||
"eslint": "7.7.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"jest": "26.4.2", | ||
"prettier": "2.1.1", | ||
"terser-webpack-plugin": "^4.1.0", | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12" | ||
"gulp": "4.0.0", | ||
"gulp-header": "2.0.5", | ||
"gulp-rename": "1.4.0", | ||
"gulp-uglify": "3.0.1", | ||
"jasmine": "3.3.0", | ||
"pump": "3.0.0" | ||
} | ||
} |
@@ -17,3 +17,20 @@ # build-url | ||
Usage in the browser: | ||
``` | ||
<script src="../path/to/lib/build-url.js"></script> | ||
<script> | ||
buildUrl('http://example.com', { | ||
path: 'about', | ||
hash: 'contact', | ||
queryParams: { | ||
foo: bar, | ||
bar: ['foo', 'bar'] | ||
} | ||
}); | ||
</script> | ||
``` | ||
Usage with ES6 modules: | ||
``` | ||
import buildUrl from '../path/to/lib/build-url'; | ||
@@ -31,2 +48,17 @@ | ||
Usage with node: | ||
``` | ||
var buildUrl = require('build-url'); | ||
buildUrl('http://example.com', { | ||
path: 'about', | ||
hash: 'contact', | ||
queryParams: { | ||
foo: bar, | ||
bar: ['foo', 'bar'] | ||
} | ||
}); | ||
``` | ||
## Options | ||
@@ -62,3 +94,3 @@ | ||
If you want to change the `path`, `hash` and `queryParams` case to all lowercase then pass `lowerCase` as true in arguments, default value of this will be `false`: | ||
If you want to change the `path`, `hash` and `queryParams` case to all lowercase then pass `lowerCase` as true in arguments, default value of this will be `false`: | ||
@@ -93,2 +125,3 @@ ``` | ||
If you only want the query string, path, hash, or any combination of the three you can skip the URL parameter or pass in an empty string or null: | ||
@@ -95,0 +128,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
23006
6
11
515
168