normalize-url
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -77,3 +77,3 @@ 'use strict'; | ||
// `urlObj.pathname = urlObj.pathname.replace(/(?<!https?:)\/{2,}/g, '/');` | ||
urlObj.pathname = urlObj.pathname.replace(/((?![https?:]).)\/{2,}/g, (_, p1) => { | ||
urlObj.pathname = urlObj.pathname.replace(/((?!:).|^)\/{2,}/g, (_, p1) => { | ||
if (/^(?!\/)/g.test(p1)) { | ||
@@ -133,2 +133,6 @@ return `${p1}/`; | ||
if (options.removeTrailingSlash) { | ||
urlObj.pathname = urlObj.pathname.replace(/\/$/, ''); | ||
} | ||
// Take advantage of many of the Node `url` normalizations | ||
@@ -138,3 +142,3 @@ urlString = urlObj.toString(); | ||
// Remove ending `/` | ||
if (options.removeTrailingSlash || urlObj.pathname === '/') { | ||
if ((options.removeTrailingSlash || urlObj.pathname === '/') && urlObj.hash === '') { | ||
urlString = urlString.replace(/\/$/, ''); | ||
@@ -141,0 +145,0 @@ } |
{ | ||
"name": "normalize-url", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Normalize a URL", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
11018
126