Socket
Socket
Sign inDemoInstall

normalize-url

Package Overview
Dependencies
0
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.4.0 to 4.4.1

22

index.js

@@ -9,4 +9,4 @@ 'use strict';

const normalizeDataURL = urlString => {
const parts = urlString.trim().match(/^data:(.*?),(.*)$/);
const normalizeDataURL = (urlString, {stripHash}) => {
const parts = urlString.match(/^data:(.*?),(.*?)(?:#(.*))?$/);

@@ -19,2 +19,3 @@ if (!parts) {

const body = parts[2];
const hash = stripHash ? '' : parts[3];

@@ -40,3 +41,3 @@ let base64 = false;

return `${key}=${value}`;
return `${key}${value ? `=${value}` : ''}`;
});

@@ -56,3 +57,3 @@

return `data:${normalizedMediaType.join(';')},${base64 ? body.trim() : body}`;
return `data:${normalizedMediaType.join(';')},${base64 ? body.trim() : body}${hash ? `#${hash}` : ''}`;
};

@@ -91,2 +92,7 @@

// Data URL
if (/^data:/i.test(urlString)) {
return normalizeDataURL(urlString, options);
}
const hasRelativeProtocol = urlString.startsWith('//');

@@ -96,3 +102,3 @@ const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString);

// Prepend protocol
if (!isRelativeUrl && !/^data:/i.test(urlString)) {
if (!isRelativeUrl) {
urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol);

@@ -186,8 +192,2 @@ }

// Data URL
if (urlObj.protocol === 'data:') {
const url = normalizeDataURL(`${urlObj.protocol}${urlObj.pathname}`);
return `${url}${urlObj.search}${urlObj.hash}`;
}
if (options.removeTrailingSlash) {

@@ -194,0 +194,0 @@ urlObj.pathname = urlObj.pathname.replace(/\/$/, '');

{
"name": "normalize-url",
"version": "4.4.0",
"version": "4.4.1",
"description": "Normalize a URL",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc