Socket
Socket
Sign inDemoInstall

url-parse

Package Overview
Dependencies
2
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.3 to 1.5.4

22

dist/url-parse.js

@@ -377,3 +377,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.URLParse = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

instruction = url.auth.split(':');
url.username = instruction[0] || '';
url.username = instruction[0];
url.password = instruction[1] || '';

@@ -465,4 +465,11 @@ }

default:
url[part] = value;
case 'username':
case 'password':
url[part] = encodeURIComponent(value);
break;
case 'auth':
var splits = value.split(':');
url.username = splits[0];
url.password = splits.length === 2 ? splits[1] : '';
}

@@ -476,2 +483,4 @@

url.auth = url.password ? url.username +':'+ url.password : url.username;
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host

@@ -502,3 +511,5 @@ ? url.protocol +'//'+ url.host

var result = protocol + (url.slashes || isSpecial(url.protocol) ? '//' : '');
var result =
protocol +
((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : '');

@@ -509,2 +520,5 @@ if (url.username) {

result += '@';
} else if (url.password) {
result += ':'+ url.password;
result += '@';
}

@@ -511,0 +525,0 @@

2

dist/url-parse.min.js

@@ -1,1 +0,1 @@

!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).URLParse=e()}(function(){return function r(n,s,a){function i(t,e){if(!s[t]){if(!n[t]){var o="function"==typeof require&&require;if(!e&&o)return o(t,!0);if(u)return u(t,!0);throw(o=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",o}o=s[t]={exports:{}},n[t][0].call(o.exports,function(e){return i(n[t][1][e]||e)},o,o.exports,r,n,s,a)}return s[t].exports}for(var u="function"==typeof require&&require,e=0;e<a.length;e++)i(a[e]);return i}({1:[function(e,o,t){!function(a){!function(){"use strict";var f=e("requires-port"),h=e("querystringify"),n=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,i=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,d=/^[a-zA-Z]:/,t=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function y(e){return(e||"").toString().replace(t,"")}var g=[["#","hash"],["?","query"],function(e,t){return w(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],s={hash:1,query:1};function m(e){var t,o="undefined"!=typeof window?window:void 0!==a?a:"undefined"!=typeof self?self:{},o=o.location||{},r={},o=typeof(e=e||o);if("blob:"===e.protocol)r=new v(unescape(e.pathname),{});else if("string"==o)for(t in r=new v(e,{}),s)delete r[t];else if("object"==o){for(t in e)t in s||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=n.test(e.href))}return r}function w(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function x(e,t){e=y(e),t=t||{};var o,r=i.exec(e),n=r[1]?r[1].toLowerCase():"",s=!!r[2],a=!!r[3],e=0;return s?e=a?(o=r[2]+r[3]+r[4],r[2].length+r[3].length):(o=r[2]+r[4],r[2].length):a?(o=r[3]+r[4],e=r[3].length):o=r[4],"file:"===n?2<=e&&(o=o.slice(2)):w(n)?o=r[4]:n?s&&(o=o.slice(2)):2<=e&&w(t.protocol)&&(o=r[4]),{protocol:n,slashes:s||w(n),slashesCount:e,rest:o}}function v(e,t,o){if(e=y(e),!(this instanceof v))return new v(e,t,o);var r,n,s,a,i,u=g.slice(),l=typeof t,c=this,p=0;for("object"!=l&&"string"!=l&&(o=t,t=null),o&&"function"!=typeof o&&(o=h.parse),r=!(l=x(e||"",t=m(t))).protocol&&!l.slashes,c.slashes=l.slashes||r&&t.slashes,c.protocol=l.protocol||t.protocol||"",e=l.rest,("file:"===l.protocol&&(2!==l.slashesCount||d.test(e))||!l.slashes&&(l.protocol||l.slashesCount<2||!w(c.protocol)))&&(u[3]=[/(.*)/,"pathname"]);p<u.length;p++)"function"!=typeof(s=u[p])?(n=s[0],i=s[1],n!=n?c[i]=e:"string"==typeof n?~(a=e.indexOf(n))&&(e="number"==typeof s[2]?(c[i]=e.slice(0,a),e.slice(a+s[2])):(c[i]=e.slice(a),e.slice(0,a))):(a=n.exec(e))&&(c[i]=a[1],e=e.slice(0,a.index)),c[i]=c[i]||r&&s[3]&&t[i]||"",s[4]&&(c[i]=c[i].toLowerCase())):e=s(e,c);o&&(c.query=o(c.query)),r&&t.slashes&&"/"!==c.pathname.charAt(0)&&(""!==c.pathname||""!==t.pathname)&&(c.pathname=function(e,t){if(""===e)return t;for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=o.length,e=o[r-1],n=!1,s=0;r--;)"."===o[r]?o.splice(r,1):".."===o[r]?(o.splice(r,1),s++):s&&(0===r&&(n=!0),o.splice(r,1),s--);return n&&o.unshift(""),"."!==e&&".."!==e||o.push(""),o.join("/")}(c.pathname,t.pathname)),"/"!==c.pathname.charAt(0)&&w(c.protocol)&&(c.pathname="/"+c.pathname),f(c.port,c.protocol)||(c.host=c.hostname,c.port=""),c.username=c.password="",c.auth&&(s=c.auth.split(":"),c.username=s[0]||"",c.password=s[1]||""),c.origin="file:"!==c.protocol&&w(c.protocol)&&c.host?c.protocol+"//"+c.host:"null",c.href=c.toString()}v.prototype={set:function(e,t,o){var r,n=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(o||h.parse)(t)),n[e]=t;break;case"port":n[e]=t,f(t,n.protocol)?t&&(n.host=n.hostname+":"+t):(n.host=n.hostname,n[e]="");break;case"hostname":n[e]=t,n.port&&(t+=":"+n.port),n.host=t;break;case"host":n[e]=t,/:\d+$/.test(t)?(t=t.split(":"),n.port=t.pop(),n.hostname=t.join(":")):(n.hostname=t,n.port="");break;case"protocol":n.protocol=t.toLowerCase(),n.slashes=!o;break;case"pathname":case"hash":t?(r="pathname"===e?"/":"#",n[e]=t.charAt(0)!==r?r+t:t):n[e]=t;break;default:n[e]=t}for(var s=0;s<g.length;s++){var a=g[s];a[4]&&(n[a[1]]=n[a[1]].toLowerCase())}return n.origin="file:"!==n.protocol&&w(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n},toString:function(e){e&&"function"==typeof e||(e=h.stringify);var t=this,o=t.protocol;return o&&":"!==o.charAt(o.length-1)&&(o+=":"),o+=t.slashes||w(t.protocol)?"//":"",t.username&&(o+=t.username,t.password&&(o+=":"+t.password),o+="@"),o+=t.host+t.pathname,(e="object"==typeof t.query?e(t.query):t.query)&&(o+="?"!==e.charAt(0)?"?"+e:e),t.hash&&(o+=t.hash),o}},v.extractProtocol=x,v.location=m,v.trimLeft=y,v.qs=h,o.exports=v}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{querystringify:2,"requires-port":3}],2:[function(e,t,o){"use strict";var s=Object.prototype.hasOwnProperty;function a(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function i(e){try{return encodeURIComponent(e)}catch(e){return null}}o.stringify=function(e,t){var o,r,n=[];for(r in"string"!=typeof(t=t||"")&&(t="?"),e)s.call(e,r)&&((o=e[r])||null!=o&&!isNaN(o)||(o=""),r=i(r),o=i(o),null!==r&&null!==o&&n.push(r+"="+o));return n.length?t+n.join("&"):""},o.parse=function(e){for(var t=/([^=?#&]+)=?([^&]*)/g,o={};n=t.exec(e);){var r=a(n[1]),n=a(n[2]);null===r||null===n||r in o||(o[r]=n)}return o}},{}],3:[function(e,t,o){"use strict";t.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},{}]},{},[1])(1)});
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).URLParse=e()}(function(){return function r(n,s,a){function i(t,e){if(!s[t]){if(!n[t]){var o="function"==typeof require&&require;if(!e&&o)return o(t,!0);if(u)return u(t,!0);throw(o=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",o}o=s[t]={exports:{}},n[t][0].call(o.exports,function(e){return i(n[t][1][e]||e)},o,o.exports,r,n,s,a)}return s[t].exports}for(var u="function"==typeof require&&require,e=0;e<a.length;e++)i(a[e]);return i}({1:[function(e,o,t){!function(a){!function(){"use strict";var f=e("requires-port"),h=e("querystringify"),n=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,i=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,d=/^[a-zA-Z]:/,t=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function y(e){return(e||"").toString().replace(t,"")}var m=[["#","hash"],["?","query"],function(e,t){return g(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],s={hash:1,query:1};function w(e){var t,o="undefined"!=typeof window?window:void 0!==a?a:"undefined"!=typeof self?self:{},o=o.location||{},r={},o=typeof(e=e||o);if("blob:"===e.protocol)r=new x(unescape(e.pathname),{});else if("string"==o)for(t in r=new x(e,{}),s)delete r[t];else if("object"==o){for(t in e)t in s||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=n.test(e.href))}return r}function g(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function v(e,t){e=y(e),t=t||{};var o,r=i.exec(e),n=r[1]?r[1].toLowerCase():"",s=!!r[2],a=!!r[3],e=0;return s?e=a?(o=r[2]+r[3]+r[4],r[2].length+r[3].length):(o=r[2]+r[4],r[2].length):a?(o=r[3]+r[4],e=r[3].length):o=r[4],"file:"===n?2<=e&&(o=o.slice(2)):g(n)?o=r[4]:n?s&&(o=o.slice(2)):2<=e&&g(t.protocol)&&(o=r[4]),{protocol:n,slashes:s||g(n),slashesCount:e,rest:o}}function x(e,t,o){if(e=y(e),!(this instanceof x))return new x(e,t,o);var r,n,s,a,i,u=m.slice(),l=typeof t,p=this,c=0;for("object"!=l&&"string"!=l&&(o=t,t=null),o&&"function"!=typeof o&&(o=h.parse),r=!(l=v(e||"",t=w(t))).protocol&&!l.slashes,p.slashes=l.slashes||r&&t.slashes,p.protocol=l.protocol||t.protocol||"",e=l.rest,("file:"===l.protocol&&(2!==l.slashesCount||d.test(e))||!l.slashes&&(l.protocol||l.slashesCount<2||!g(p.protocol)))&&(u[3]=[/(.*)/,"pathname"]);c<u.length;c++)"function"!=typeof(s=u[c])?(n=s[0],i=s[1],n!=n?p[i]=e:"string"==typeof n?~(a=e.indexOf(n))&&(e="number"==typeof s[2]?(p[i]=e.slice(0,a),e.slice(a+s[2])):(p[i]=e.slice(a),e.slice(0,a))):(a=n.exec(e))&&(p[i]=a[1],e=e.slice(0,a.index)),p[i]=p[i]||r&&s[3]&&t[i]||"",s[4]&&(p[i]=p[i].toLowerCase())):e=s(e,p);o&&(p.query=o(p.query)),r&&t.slashes&&"/"!==p.pathname.charAt(0)&&(""!==p.pathname||""!==t.pathname)&&(p.pathname=function(e,t){if(""===e)return t;for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=o.length,e=o[r-1],n=!1,s=0;r--;)"."===o[r]?o.splice(r,1):".."===o[r]?(o.splice(r,1),s++):s&&(0===r&&(n=!0),o.splice(r,1),s--);return n&&o.unshift(""),"."!==e&&".."!==e||o.push(""),o.join("/")}(p.pathname,t.pathname)),"/"!==p.pathname.charAt(0)&&g(p.protocol)&&(p.pathname="/"+p.pathname),f(p.port,p.protocol)||(p.host=p.hostname,p.port=""),p.username=p.password="",p.auth&&(s=p.auth.split(":"),p.username=s[0],p.password=s[1]||""),p.origin="file:"!==p.protocol&&g(p.protocol)&&p.host?p.protocol+"//"+p.host:"null",p.href=p.toString()}x.prototype={set:function(e,t,o){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(o||h.parse)(t)),r[e]=t;break;case"port":r[e]=t,f(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!o;break;case"pathname":case"hash":t?(n="pathname"===e?"/":"#",r[e]=t.charAt(0)!==n?n+t:t):r[e]=t;break;case"username":case"password":r[e]=encodeURIComponent(t);break;case"auth":var n=t.split(":");r.username=n[0],r.password=2===n.length?n[1]:""}for(var s=0;s<m.length;s++){var a=m[s];a[4]&&(r[a[1]]=r[a[1]].toLowerCase())}return r.auth=r.password?r.username+":"+r.password:r.username,r.origin="file:"!==r.protocol&&g(r.protocol)&&r.host?r.protocol+"//"+r.host:"null",r.href=r.toString(),r},toString:function(e){e&&"function"==typeof e||(e=h.stringify);var t=this,o=t.protocol;return o&&":"!==o.charAt(o.length-1)&&(o+=":"),o+=t.protocol&&t.slashes||g(t.protocol)?"//":"",t.username?(o+=t.username,t.password&&(o+=":"+t.password),o+="@"):t.password&&(o+=":"+t.password,o+="@"),o+=t.host+t.pathname,(e="object"==typeof t.query?e(t.query):t.query)&&(o+="?"!==e.charAt(0)?"?"+e:e),t.hash&&(o+=t.hash),o}},x.extractProtocol=v,x.location=w,x.trimLeft=y,x.qs=h,o.exports=x}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{querystringify:2,"requires-port":3}],2:[function(e,t,o){"use strict";var s=Object.prototype.hasOwnProperty;function a(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function i(e){try{return encodeURIComponent(e)}catch(e){return null}}o.stringify=function(e,t){var o,r,n=[];for(r in"string"!=typeof(t=t||"")&&(t="?"),e)s.call(e,r)&&((o=e[r])||null!=o&&!isNaN(o)||(o=""),r=i(r),o=i(o),null!==r&&null!==o&&n.push(r+"="+o));return n.length?t+n.join("&"):""},o.parse=function(e){for(var t=/([^=?#&]+)=?([^&]*)/g,o={};n=t.exec(e);){var r=a(n[1]),n=a(n[2]);null===r||null===n||r in o||(o[r]=n)}return o}},{}],3:[function(e,t,o){"use strict";t.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},{}]},{},[1])(1)});

@@ -375,3 +375,3 @@ 'use strict';

instruction = url.auth.split(':');
url.username = instruction[0] || '';
url.username = instruction[0];
url.password = instruction[1] || '';

@@ -463,4 +463,11 @@ }

default:
url[part] = value;
case 'username':
case 'password':
url[part] = encodeURIComponent(value);
break;
case 'auth':
var splits = value.split(':');
url.username = splits[0];
url.password = splits.length === 2 ? splits[1] : '';
}

@@ -474,2 +481,4 @@

url.auth = url.password ? url.username +':'+ url.password : url.username;
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host

@@ -500,3 +509,5 @@ ? url.protocol +'//'+ url.host

var result = protocol + (url.slashes || isSpecial(url.protocol) ? '//' : '');
var result =
protocol +
((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : '');

@@ -507,2 +518,5 @@ if (url.username) {

result += '@';
} else if (url.password) {
result += ':'+ url.password;
result += '@';
}

@@ -509,0 +523,0 @@

{
"name": "url-parse",
"version": "1.5.3",
"version": "1.5.4",
"description": "Small footprint URL parser that works seamlessly across Node.js and browser environments",
"main": "index.js",
"scripts": {
"browserify": "rm -rf dist && mkdir -p dist && browserify index.js -s URLParse -o dist/url-parse.js",
"browserify": "browserify index.js -s URLParse -o dist/url-parse.js",
"minify": "uglifyjs dist/url-parse.js --source-map -cm -o dist/url-parse.min.js",

@@ -43,3 +43,3 @@ "test": "c8 --reporter=lcov --reporter=text mocha test/test.js",

"c8": "^7.3.1",
"mocha": "^8.0.1",
"mocha": "^9.0.3",
"pre-commit": "^1.2.2",

@@ -46,0 +46,0 @@ "sauce-browsers": "^2.0.0",

# url-parse
[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](https://img.shields.io/npm/v/url-parse.svg?style=flat-square)](https://www.npmjs.com/package/url-parse)[![Build Status](https://img.shields.io/github/workflow/status/unshiftio/url-parse/CI/master?label=CI&style=flat-square)](https://github.com/unshiftio/url-parse/actions?query=workflow%3ACI+branch%3Amaster)[![Dependencies](https://img.shields.io/david/unshiftio/url-parse.svg?style=flat-square)](https://david-dm.org/unshiftio/url-parse)[![Coverage Status](https://img.shields.io/coveralls/unshiftio/url-parse/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/url-parse?branch=master)[![IRC channel](https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](https://webchat.freenode.net/?channels=unshift)
[![Version npm](https://img.shields.io/npm/v/url-parse.svg?style=flat-square)](https://www.npmjs.com/package/url-parse)[![Build Status](https://img.shields.io/github/workflow/status/unshiftio/url-parse/CI/master?label=CI&style=flat-square)](https://github.com/unshiftio/url-parse/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/unshiftio/url-parse/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/url-parse?branch=master)

@@ -5,0 +5,0 @@ [![Sauce Test Status](https://saucelabs.com/browser-matrix/url-parse.svg)](https://saucelabs.com/u/url-parse)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc