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

iso-url

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iso-url - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

10

changelog.md

@@ -0,1 +1,11 @@

## [0.4.1](https://github.com/hugomrdias/iso-url/compare/v0.4.0...v0.4.1) (2018-12-15)
### Bug Fixes
* better support format in the browser ([77070e5](https://github.com/hugomrdias/iso-url/commit/77070e5))
* better support format in the browser ([9c2d83b](https://github.com/hugomrdias/iso-url/commit/9c2d83b))
# [0.4.0](https://github.com/hugomrdias/iso-url/compare/v0.3.0...v0.4.0) (2018-12-15)

@@ -2,0 +12,0 @@

46

index.js
'use strict';
const { URL, URLSearchParams, format } = require('url');
const {
URLWithLegacySupport,
format,
URLSearchParams,
defaultBase
} = require('./src/url');
const relative = require('./src/relative');
// https://github.com/nodejs/node/issues/12682
const defaultBase = 'http://localhost';
class URLWithLegacySupport extends URL {
constructor(url, base = defaultBase) {
super(url, base);
this.path = this.pathname + this.search;
this.auth =
this.username && this.password ?
this.username + ':' + this.password :
null;
this.query =
this.search && this.search.startsWith('?') ?
this.search.slice(1) :
null;
}
format() {
return this.toString();
}
}
const relative = (url, location = {}, protocolMap = {}, defaultProtocol) => {
let protocol = location.protocol ?
location.protocol.replace(':', '') :
'http';
// Check protocol map
protocol = (protocolMap[protocol] || defaultProtocol || protocol) + ':';
const b = Object.assign({}, location, { protocol });
return new URLWithLegacySupport(url, format(b)).toString();
};
module.exports = {

@@ -44,3 +15,4 @@ URL: URLWithLegacySupport,

format,
relative
relative,
defaultBase
};
{
"name": "iso-url",
"version": "0.4.0",
"version": "0.4.1",
"description": "Isomorphic/Universal WHATWG URL API with some support legacy node URL API",

@@ -13,6 +13,6 @@ "repository": "hugomrdias/iso-url",

"browser": {
"./index.js": "./index-browser.js"
"./src/url.js": "./src/url-browser.js"
},
"scripts": {
"test": "nyc tape test.js | faucet",
"test": "nyc tape test.js",
"test:browser-local": "airtap --local test.js",

@@ -41,3 +41,2 @@ "lint": "eslint --cache *.js src/*.js",

"eslint-config-halo": "^2.3.3",
"faucet": "^0.0.1",
"http-serve": "^1.0.1",

@@ -44,0 +43,0 @@ "husky": "^1.2.0",

@@ -7,2 +7,6 @@ # iso-url [![NPM Version](https://img.shields.io/npm/v/iso-url.svg)](https://www.npmjs.com/package/iso-url) [![NPM Downloads](https://img.shields.io/npm/dt/iso-url.svg)](https://www.npmjs.com/package/iso-url) [![NPM License](https://img.shields.io/npm/l/iso-url.svg)](https://www.npmjs.com/package/iso-url) [![Build Status](https://travis-ci.org/hugomrdias/iso-url.svg?branch=master)](https://travis-ci.org/hugomrdias/iso-url) [![codecov](https://codecov.io/gh/hugomrdias/iso-url/badge.svg?branch=master)](https://codecov.io/gh/hugomrdias/iso-url?branch=master)

## Caveats
No support for querystring objects. Use `URLSearchParams`.
## Install

@@ -9,0 +13,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