normalize-url
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -13,2 +13,3 @@ 'use strict'; | ||
normalizeHttps: false, | ||
normalizeHttp: false, | ||
stripFragment: true, | ||
@@ -34,2 +35,10 @@ stripWWW: true, | ||
if (opts.normalizeHttps && opts.normalizeHttp) { | ||
throw new Error('The `normalizeHttp` and `normalizeHttps` options cannot be used together'); | ||
} | ||
if (opts.normalizeHttp && urlObj.protocol === 'http:') { | ||
urlObj.protocol = 'https:'; | ||
} | ||
if (opts.normalizeHttps && urlObj.protocol === 'https:') { | ||
@@ -36,0 +45,0 @@ urlObj.protocol = 'http:'; |
{ | ||
"name": "normalize-url", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Normalize a URL", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -72,2 +72,19 @@ # normalize-url [![Build Status](https://travis-ci.org/sindresorhus/normalize-url.svg?branch=master)](https://travis-ci.org/sindresorhus/normalize-url) | ||
##### normalizeHttp | ||
Type: `boolean`<br> | ||
Default: `false` | ||
Normalize `http:` URLs to `https:`. | ||
```js | ||
normalizeUrl('https://sindresorhus.com:80/'); | ||
//=> 'https://sindresorhus.com' | ||
normalizeUrl('http://sindresorhus.com:80/', {normalizeHttp: true}); | ||
//=> 'https://sindresorhus.com' | ||
``` | ||
This option is mutually exclusive with the `normalizeHttps` option. | ||
##### stripFragment | ||
@@ -74,0 +91,0 @@ |
8742
91
190