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

poly-js-utils

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poly-js-utils - npm Package Compare versions

Comparing version 1.2.9 to 1.2.10

2

package.json
{
"name": "poly-js-utils",
"version": "1.2.9",
"version": "1.2.10",
"description": "Common client-side tools used in HSS Sites themes and locators.",

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

@@ -76,2 +76,24 @@ var utils = require('../src/utils');

});
it("should return properly when the url is relative", function() {
var url = "www.example.com/example/ex";
var parsed = utils.parseUrl(url);
expect(parsed.hash).toBe("");
expect(parsed.hostname).toBe("www.example.com");
expect(parsed.pathname).toBe("/example/ex");
expect(parsed.port).toBe("");
expect(parsed.protocol).toBe("http:");
expect(parsed.search).toBe("");
});
it("should return properly when the url is a path", function() {
var url = "/example/ex";
var parsed = utils.parseUrl(url);
expect(parsed.hash).toBe("");
expect(parsed.hostname).toBe("");
expect(parsed.pathname).toBe("/example/ex");
expect(parsed.port).toBe("");
expect(parsed.protocol).toBe("http:");
expect(parsed.search).toBe("");
});
});

@@ -78,0 +100,0 @@

@@ -32,3 +32,4 @@ var _ = require('underscore');

// Don't want url to be treated as relative (path)
a.href = makeAbsolute(url);
var absoluteUrl = makeAbsolute(url);
a.href = absoluteUrl;

@@ -38,2 +39,11 @@ var parts = ["protocol", "hostname", "port", "pathname", "search", "hash"];

if(!isAbsolute) {
var splitHref = absoluteUrl.split(/^\/\/\//);
// Checks that url is truly a path (i.e. it follows the "/example" format instead of "www.example.com" format)
if(splitHref[1]) {
parsed.hostname = splitHref[0];
parsed.pathname = splitHref[1];
}
}
// Make sure the pathname always beings with a /

@@ -52,3 +62,2 @@ if (parsed.pathname &&

parsed.toString = parsed.getUrl;
return parsed;

@@ -55,0 +64,0 @@ };

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