normalize-url
Advanced tools
Comparing version 1.5.3 to 1.6.0
@@ -40,3 +40,4 @@ 'use strict'; | ||
stripWWW: true, | ||
removeQueryParameters: [/^utm_\w+/i] | ||
removeQueryParameters: [/^utm_\w+/i], | ||
removeTrailingSlash: true | ||
}, opts); | ||
@@ -125,3 +126,5 @@ | ||
// remove ending `/` | ||
str = str.replace(/\/$/, ''); | ||
if (opts.removeTrailingSlash || urlObj.pathname === '/') { | ||
str = str.replace(/\/$/, ''); | ||
} | ||
@@ -128,0 +131,0 @@ // restore relative protocol, if applicable |
{ | ||
"name": "normalize-url", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Normalize a URL", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -99,3 +99,23 @@ # normalize-url [![Build Status](https://travis-ci.org/sindresorhus/normalize-url.svg?branch=master)](https://travis-ci.org/sindresorhus/normalize-url) | ||
##### removeTrailingSlash | ||
Type: `boolean`<br> | ||
Default: `true` | ||
Remove trailing slash. | ||
**Note:** Trailing slash is always removed if the URL doesn't have a pathname. | ||
```js | ||
normalizeUrl('http://sindresorhus.com/redirect/'); | ||
//=> 'http://sindresorhus.com/redirect' | ||
normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false}); | ||
//=> 'http://sindresorhus.com/redirect/' | ||
normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false}); | ||
//=> 'http://sindresorhus.com' | ||
``` | ||
## Related | ||
@@ -102,0 +122,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7818
109
128