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.1.8 to 1.1.9

README.md

54

index.js
'use strict';
var required = require('requires-port')
, lolcation = require('./lolcation')
, qs = require('querystringify')
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i;
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;

@@ -31,2 +31,50 @@ /**

/**
* These properties should not be copied or inherited from. This is only needed
* for all non blob URL's as a blob URL does not include a hash, only the
* origin.
*
* @type {Object}
* @private
*/
var ignore = { hash: 1, query: 1 };
/**
* The location object differs when your code is loaded through a normal page,
* Worker or through a worker using a blob. And with the blobble begins the
* trouble as the location object will contain the URL of the blob, not the
* location of the page where our code is loaded in. The actual origin is
* encoded in the `pathname` so we can thankfully generate a good "default"
* location from it so we can generate proper relative URL's again.
*
* @param {Object|String} loc Optional default location object.
* @returns {Object} lolcation object.
* @api public
*/
function lolcation(loc) {
loc = loc || global.location || {};
var finaldestination = {}
, type = typeof loc
, key;
if ('blob:' === loc.protocol) {
finaldestination = new URL(unescape(loc.pathname), {});
} else if ('string' === type) {
finaldestination = new URL(loc, {});
for (key in ignore) delete finaldestination[key];
} else if ('object' === type) {
for (key in loc) {
if (key in ignore) continue;
finaldestination[key] = loc[key];
}
if (finaldestination.slashes === undefined) {
finaldestination.slashes = slashes.test(loc.href);
}
}
return finaldestination;
}
/**
* @typedef ProtocolExtract

@@ -314,3 +362,3 @@ * @type Object

return url;
};
}

@@ -317,0 +365,0 @@ /**

10

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

@@ -33,10 +33,10 @@ "main": "index.js",

"dependencies": {
"querystringify": "0.0.x",
"querystringify": "~1.0.0",
"requires-port": "1.0.x"
},
"devDependencies": {
"assume": "1.4.x",
"browserify": "~14.1.0",
"assume": "~1.5.0",
"browserify": "~14.3.0",
"istanbul": "0.4.x",
"mocha": "~3.2.0",
"mocha": "~3.3.0",
"pre-commit": "~1.2.0",

@@ -43,0 +43,0 @@ "zuul": "3.11.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