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

url-parse

Package Overview
Dependencies
Maintainers
3
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.1.1 to 1.1.2

49

index.js

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

, relativere = /^\/(?!\/)/
, protocolre = /^([a-z0-9.+-]+:)?(\/\/)?(.*)$/i; // actual protocol is first match
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i;

@@ -28,3 +28,3 @@ /**

[NaN, 'host', undefined, 1, 1], // Set left over value.
[/\:(\d+)$/, 'port'], // RegExp the back.
[/:(\d+)$/, 'port'], // RegExp the back.
[NaN, 'hostname', undefined, 1, 1] // Set left over.

@@ -46,6 +46,7 @@ ];

* @return {ProtocolExtract} Extracted information
* @private
* @api private
*/
function extractProtocol(address) {
var match = protocolre.exec(address);
return {

@@ -61,3 +62,3 @@ protocol: match[1] ? match[1].toLowerCase() : '',

* create an actual constructor as it's much more memory efficient and
* faster and it pleases my CDO.
* faster and it pleases my OCD.
*

@@ -79,2 +80,3 @@ * @constructor

, url = this
, extracted
, i = 0;

@@ -104,4 +106,6 @@

//
// extract protocol information before running the instructions
var extracted = extractProtocol(address);
//
extracted = extractProtocol(address);
url.protocol = extracted.protocol || location.protocol || '';

@@ -174,2 +178,3 @@ url.slashes = extracted.slashes || location.slashes;

//
url.origin = url.protocol && url.host ? url.protocol +'//'+ url.host : 'null';
url.href = url.toString();

@@ -182,3 +187,3 @@ }

*
* @param {String} prop Property we need to adjust.
* @param {String} part Property we need to adjust.
* @param {Mixed} value The newly assigned value.

@@ -218,9 +223,12 @@ * @param {Boolean|Function} fn When setting the query, it will be the function used to parse

if (/\:\d+/.test(value)) {
if (/:\d+$/.test(value)) {
value = value.split(':');
url.hostname = value[0];
url.port = value[1];
url.port = value.pop();
url.hostname = value.join(':');
} else {
url.hostname = value;
url.port = '';
}
} else if ('protocol' === part) {
url.protocol = value;
url.protocol = value.toLowerCase();
url.slashes = !fn;

@@ -231,3 +239,13 @@ } else {

for (var i = 0; i < instructions.length; i++) {
var ins = instructions[i];
if (ins[4]) {
url[ins[1]] = url[ins[1]].toLowerCase();
}
}
url.origin = url.protocol && url.host ? url.protocol +'//'+ url.host : 'null';
url.href = url.toString();
return url;

@@ -260,7 +278,4 @@ };

result += url.hostname;
if (url.port) result += ':'+ url.port;
result += url.host + url.pathname;
result += url.pathname;
query = 'object' === typeof url.query ? stringify(url.query) : url.query;

@@ -276,6 +291,8 @@ if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;

// Expose the URL parser and some additional properties that might be useful for
// others.
// others or testing.
//
URL.extractProtocol = extractProtocol;
URL.location = lolcation;
URL.qs = qs;
URL.location = lolcation;
module.exports = URL;
{
"name": "url-parse",
"version": "1.1.1",
"version": "1.1.2",
"description": "Small footprint URL parser that works seamlessly across Node.js and browser environments",

@@ -40,3 +40,3 @@ "main": "index.js",

"istanbul": "0.4.x",
"mocha": "2.4.x",
"mocha": "2.5.x",
"pre-commit": "1.1.x",

@@ -43,0 +43,0 @@ "zuul": "3.10.x"

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