Socket
Socket
Sign inDemoInstall

url-parse

Package Overview
Dependencies
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-parse - npm Package Compare versions

Comparing version 1.5.5 to 1.5.6

37

dist/url-parse.js

@@ -311,3 +311,7 @@ (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){

} else if ('string' === typeof parse) {
if (~(index = address.indexOf(parse))) {
index = parse === '@'
? address.lastIndexOf(parse)
: address.indexOf(parse);
if (~index) {
if ('number' === typeof instruction[2]) {

@@ -378,6 +382,17 @@ url[key] = address.slice(0, index);

url.username = url.password = '';
if (url.auth) {
instruction = url.auth.split(':');
url.username = instruction[0];
url.password = instruction[1] || '';
index = url.auth.indexOf(':');
if (~index) {
url.username = url.auth.slice(0, index);
url.username = encodeURIComponent(decodeURIComponent(url.username));
url.password = url.auth.slice(index + 1);
url.password = encodeURIComponent(decodeURIComponent(url.password))
} else {
url.username = encodeURIComponent(decodeURIComponent(url.auth));
}
url.auth = url.password ? url.username +':'+ url.password : url.username;
}

@@ -474,5 +489,13 @@

case 'auth':
var splits = value.split(':');
url.username = splits[0];
url.password = splits.length === 2 ? splits[1] : '';
var index = value.indexOf(':');
if (~index) {
url.username = value.slice(0, index);
url.username = encodeURIComponent(decodeURIComponent(url.username));
url.password = value.slice(index + 1);
url.password = encodeURIComponent(decodeURIComponent(url.password));
} else {
url.username = encodeURIComponent(decodeURIComponent(value));
}
}

@@ -479,0 +502,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(l)return l(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}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 l="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"),d=/[\n\r\t]/g,s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,i=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,q=/^[a-zA-Z]:/,t=/^[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\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]],n={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 b(unescape(e.pathname),{});else if("string"==o)for(t in r=new b(e,{}),n)delete r[t];else if("object"==o){for(t in e)t in n||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=s.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=(e=y(e)).replace(d,""),t=t||{};var o,e=i.exec(e),r=e[1]?e[1].toLowerCase():"",n=!!e[2],s=!!e[3],a=0;return n?a=s?(o=e[2]+e[3]+e[4],e[2].length+e[3].length):(o=e[2]+e[4],e[2].length):s?(o=e[3]+e[4],a=e[3].length):o=e[4],"file:"===r?2<=a&&(o=o.slice(2)):g(r)?o=e[4]:r?n&&(o=o.slice(2)):2<=a&&g(t.protocol)&&(o=e[4]),{protocol:r,slashes:n||g(r),slashesCount:a,rest:o}}function b(e,t,o){if(e=(e=y(e)).replace(d,""),!(this instanceof b))return new b(e,t,o);var r,n,s,a,i,p=m.slice(),l=typeof t,u=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,u.slashes=l.slashes||r&&t.slashes,u.protocol=l.protocol||t.protocol||"",e=l.rest,("file:"===l.protocol&&(2!==l.slashesCount||q.test(e))||!l.slashes&&(l.protocol||l.slashesCount<2||!g(u.protocol)))&&(p[3]=[/(.*)/,"pathname"]);c<p.length;c++)"function"!=typeof(s=p[c])?(n=s[0],i=s[1],n!=n?u[i]=e:"string"==typeof n?~(a=e.indexOf(n))&&(e="number"==typeof s[2]?(u[i]=e.slice(0,a),e.slice(a+s[2])):(u[i]=e.slice(a),e.slice(0,a))):(a=n.exec(e))&&(u[i]=a[1],e=e.slice(0,a.index)),u[i]=u[i]||r&&s[3]&&t[i]||"",s[4]&&(u[i]=u[i].toLowerCase())):e=s(e,u);o&&(u.query=o(u.query)),r&&t.slashes&&"/"!==u.pathname.charAt(0)&&(""!==u.pathname||""!==t.pathname)&&(u.pathname=function(e,t){if(""===e)return t;for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=o.length,t=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(""),"."!==t&&".."!==t||o.push(""),o.join("/")}(u.pathname,t.pathname)),"/"!==u.pathname.charAt(0)&&g(u.protocol)&&(u.pathname="/"+u.pathname),f(u.port,u.protocol)||(u.host=u.hostname,u.port=""),u.username=u.password="",u.auth&&(s=u.auth.split(":"),u.username=s[0],u.password=s[1]||""),u.origin="file:"!==u.protocol&&g(u.protocol)&&u.host?u.protocol+"//"+u.host:"null",u.href=u.toString()}b.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=((o=t.protocol)&&":"!==o.charAt(o.length-1)&&(o+=":"),o+(t.protocol&&t.slashes||g(t.protocol)?"//":""));return t.username?(o+=t.username,t.password&&(o+=":"+t.password),o+="@"):t.password&&(o=o+(":"+t.password)+"@"),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}},b.extractProtocol=v,b.location=w,b.trimLeft=y,b.qs=h,o.exports=b}.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 n(r,s,a){function i(o,e){if(!s[o]){if(!r[o]){var t="function"==typeof require&&require;if(!e&&t)return t(o,!0);if(p)return p(o,!0);throw(e=new Error("Cannot find module '"+o+"'")).code="MODULE_NOT_FOUND",e}t=s[o]={exports:{}},r[o][0].call(t.exports,function(e){return i(r[o][1][e]||e)},t,t.exports,n,r,s,a)}return s[o].exports}for(var p="function"==typeof require&&require,e=0;e<a.length;e++)i(a[e]);return i}({1:[function(e,t,o){!function(a){!function(){"use strict";var f=e("requires-port"),h=e("querystringify"),d=/[\n\r\t]/g,s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,i=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,b=/^[a-zA-Z]:/,o=/^[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;function m(e){return(e||"").toString().replace(o,"")}var w=[["#","hash"],["?","query"],function(e,o){return g(o.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]],r={hash:1,query:1};function y(e){var o,t="undefined"!=typeof window?window:void 0!==a?a:"undefined"!=typeof self?self:{},t=t.location||{},n={},t=typeof(e=e||t);if("blob:"===e.protocol)n=new C(unescape(e.pathname),{});else if("string"==t)for(o in n=new C(e,{}),r)delete n[o];else if("object"==t){for(o in e)o in r||(n[o]=e[o]);void 0===n.slashes&&(n.slashes=s.test(e.href))}return n}function g(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function v(e,o){e=(e=m(e)).replace(d,""),o=o||{};var t,e=i.exec(e),n=e[1]?e[1].toLowerCase():"",r=!!e[2],s=!!e[3],a=0;return r?a=s?(t=e[2]+e[3]+e[4],e[2].length+e[3].length):(t=e[2]+e[4],e[2].length):s?(t=e[3]+e[4],a=e[3].length):t=e[4],"file:"===n?2<=a&&(t=t.slice(2)):g(n)?t=e[4]:n?r&&(t=t.slice(2)):2<=a&&g(o.protocol)&&(t=e[4]),{protocol:n,slashes:r||g(n),slashesCount:a,rest:t}}function C(e,o,t){if(e=(e=m(e)).replace(d,""),!(this instanceof C))return new C(e,o,t);var n,r,s,a,i,u=w.slice(),p=typeof o,c=this,l=0;for("object"!=p&&"string"!=p&&(t=o,o=null),t&&"function"!=typeof t&&(t=h.parse),n=!(p=v(e||"",o=y(o))).protocol&&!p.slashes,c.slashes=p.slashes||n&&o.slashes,c.protocol=p.protocol||o.protocol||"",e=p.rest,("file:"===p.protocol&&(2!==p.slashesCount||b.test(e))||!p.slashes&&(p.protocol||p.slashesCount<2||!g(c.protocol)))&&(u[3]=[/(.*)/,"pathname"]);l<u.length;l++)"function"!=typeof(s=u[l])?(r=s[0],i=s[1],r!=r?c[i]=e:"string"==typeof r?~(a="@"===r?e.lastIndexOf(r):e.indexOf(r))&&(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=r.exec(e))&&(c[i]=a[1],e=e.slice(0,a.index)),c[i]=c[i]||n&&s[3]&&o[i]||"",s[4]&&(c[i]=c[i].toLowerCase())):e=s(e,c);t&&(c.query=t(c.query)),n&&o.slashes&&"/"!==c.pathname.charAt(0)&&(""!==c.pathname||""!==o.pathname)&&(c.pathname=function(e,o){if(""===e)return o;for(var t=(o||"/").split("/").slice(0,-1).concat(e.split("/")),n=t.length,o=t[n-1],r=!1,s=0;n--;)"."===t[n]?t.splice(n,1):".."===t[n]?(t.splice(n,1),s++):s&&(0===n&&(r=!0),t.splice(n,1),s--);return r&&t.unshift(""),"."!==o&&".."!==o||t.push(""),t.join("/")}(c.pathname,o.pathname)),"/"!==c.pathname.charAt(0)&&g(c.protocol)&&(c.pathname="/"+c.pathname),f(c.port,c.protocol)||(c.host=c.hostname,c.port=""),c.username=c.password="",c.auth&&(~(a=c.auth.indexOf(":"))?(c.username=c.auth.slice(0,a),c.username=encodeURIComponent(decodeURIComponent(c.username)),c.password=c.auth.slice(a+1),c.password=encodeURIComponent(decodeURIComponent(c.password))):c.username=encodeURIComponent(decodeURIComponent(c.auth)),c.auth=c.password?c.username+":"+c.password:c.username),c.origin="file:"!==c.protocol&&g(c.protocol)&&c.host?c.protocol+"//"+c.host:"null",c.href=c.toString()}C.prototype={set:function(e,o,t){var n=this;switch(e){case"query":"string"==typeof o&&o.length&&(o=(t||h.parse)(o)),n[e]=o;break;case"port":n[e]=o,f(o,n.protocol)?o&&(n.host=n.hostname+":"+o):(n.host=n.hostname,n[e]="");break;case"hostname":n[e]=o,n.port&&(o+=":"+n.port),n.host=o;break;case"host":n[e]=o,/:\d+$/.test(o)?(o=o.split(":"),n.port=o.pop(),n.hostname=o.join(":")):(n.hostname=o,n.port="");break;case"protocol":n.protocol=o.toLowerCase(),n.slashes=!t;break;case"pathname":case"hash":o?(r="pathname"===e?"/":"#",n[e]=o.charAt(0)!==r?r+o:o):n[e]=o;break;case"username":case"password":n[e]=encodeURIComponent(o);break;case"auth":var r=o.indexOf(":");~r?(n.username=o.slice(0,r),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=o.slice(r+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(o))}for(var s=0;s<w.length;s++){var a=w[s];a[4]&&(n[a[1]]=n[a[1]].toLowerCase())}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin="file:"!==n.protocol&&g(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 o=this,t=((t=o.protocol)&&":"!==t.charAt(t.length-1)&&(t+=":"),t+(o.protocol&&o.slashes||g(o.protocol)?"//":""));return o.username?(t+=o.username,o.password&&(t+=":"+o.password),t+="@"):o.password&&(t=t+(":"+o.password)+"@"),t+=o.host+o.pathname,(e="object"==typeof o.query?e(o.query):o.query)&&(t+="?"!==e.charAt(0)?"?"+e:e),o.hash&&(t+=o.hash),t}},C.extractProtocol=v,C.location=y,C.trimLeft=m,C.qs=h,t.exports=C}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{querystringify:2,"requires-port":3}],2:[function(e,o,t){"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}}t.stringify=function(e,o){var t,n,r=[];for(n in"string"!=typeof(o=o||"")&&(o="?"),e)s.call(e,n)&&((t=e[n])||null!=t&&!isNaN(t)||(t=""),n=i(n),t=i(t),null!==n&&null!==t&&r.push(n+"="+t));return r.length?o+r.join("&"):""},t.parse=function(e){for(var o=/([^=?#&]+)=?([^&]*)/g,t={};r=o.exec(e);){var n=a(r[1]),r=a(r[2]);null===n||null===r||n in t||(t[n]=r)}return t}},{}],3:[function(e,o,t){"use strict";o.exports=function(e,o){if(o=o.split(":")[0],!(e=+e))return!1;switch(o){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)});

@@ -309,3 +309,7 @@ 'use strict';

} else if ('string' === typeof parse) {
if (~(index = address.indexOf(parse))) {
index = parse === '@'
? address.lastIndexOf(parse)
: address.indexOf(parse);
if (~index) {
if ('number' === typeof instruction[2]) {

@@ -376,6 +380,17 @@ url[key] = address.slice(0, index);

url.username = url.password = '';
if (url.auth) {
instruction = url.auth.split(':');
url.username = instruction[0];
url.password = instruction[1] || '';
index = url.auth.indexOf(':');
if (~index) {
url.username = url.auth.slice(0, index);
url.username = encodeURIComponent(decodeURIComponent(url.username));
url.password = url.auth.slice(index + 1);
url.password = encodeURIComponent(decodeURIComponent(url.password))
} else {
url.username = encodeURIComponent(decodeURIComponent(url.auth));
}
url.auth = url.password ? url.username +':'+ url.password : url.username;
}

@@ -472,5 +487,13 @@

case 'auth':
var splits = value.split(':');
url.username = splits[0];
url.password = splits.length === 2 ? splits[1] : '';
var index = value.indexOf(':');
if (~index) {
url.username = value.slice(0, index);
url.username = encodeURIComponent(decodeURIComponent(url.username));
url.password = value.slice(index + 1);
url.password = encodeURIComponent(decodeURIComponent(url.password));
} else {
url.username = encodeURIComponent(decodeURIComponent(value));
}
}

@@ -477,0 +500,0 @@

{
"name": "url-parse",
"version": "1.5.5",
"version": "1.5.6",
"description": "Small footprint URL parser that works seamlessly across Node.js and browser environments",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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