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

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.2 to 1.5.3

4

dist/url-parse.js

@@ -9,2 +9,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){

, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
, windowsDriveLetter = /^[a-zA-Z]:/
, whitespace = '[\\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]'

@@ -285,3 +286,4 @@ , left = new RegExp('^'+ whitespace +'+');

if (
url.protocol === 'file:' ||
extracted.protocol === 'file:' && (
extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||
(!extracted.slashes &&

@@ -288,0 +290,0 @@ (extracted.protocol ||

@@ -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,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 d(e){return(e||"").toString().replace(t,"")}var y=[["#","hash"],["?","query"],function(e,t){return m(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 g(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 m(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function w(e,t){e=d(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)):m(n)?o=r[4]:n?s&&(o=o.slice(2)):2<=e&&m(t.protocol)&&(o=r[4]),{protocol:n,slashes:s||m(n),slashesCount:e,rest:o}}function x(e,t,o){if(e=d(e),!(this instanceof x))return new x(e,t,o);var r,n,s,a,i,u=y.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=w(e||"",t=g(t))).protocol&&!l.slashes,c.slashes=l.slashes||r&&t.slashes,c.protocol=l.protocol||t.protocol||"",e=l.rest,"file:"!==c.protocol&&(l.slashes||!(l.protocol||l.slashesCount<2)&&m(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)&&m(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&&m(c.protocol)&&c.host?c.protocol+"//"+c.host:"null",c.href=c.toString()}x.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<y.length;s++){var a=y[s];a[4]&&(n[a[1]]=n[a[1]].toLowerCase())}return n.origin="file:"!==n.protocol&&m(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||m(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}},x.extractProtocol=w,x.location=g,x.trimLeft=d,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)});
!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)});

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

, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
, windowsDriveLetter = /^[a-zA-Z]:/
, whitespace = '[\\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]'

@@ -283,3 +284,4 @@ , left = new RegExp('^'+ whitespace +'+');

if (
url.protocol === 'file:' ||
extracted.protocol === 'file:' && (
extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||
(!extracted.slashes &&

@@ -286,0 +288,0 @@ (extracted.protocol ||

{
"name": "url-parse",
"version": "1.5.2",
"version": "1.5.3",
"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