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

urlpattern-polyfill

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urlpattern-polyfill - npm Package Compare versions

Comparing version 5.0.9 to 6.0.1

83

dist/urlpattern.js

@@ -229,3 +229,3 @@ // src/path-to-regex-modified.ts

function flags(options) {
return options && options.sensitive ? "u" : "ui";
return options && options.ignoreCase ? "ui" : "u";
}

@@ -995,3 +995,3 @@ function regexpToRegexp(path, keys) {

var URLPattern = class {
constructor(init = {}, baseURL) {
constructor(init = {}, baseURLOrOptions, options) {
this.regexp = {};

@@ -1001,2 +1001,8 @@ this.keys = {};

try {
let baseURL = void 0;
if (typeof baseURLOrOptions === "string") {
baseURL = baseURLOrOptions;
} else {
options = baseURLOrOptions;
}
if (typeof init === "string") {

@@ -1006,17 +1012,18 @@ const parser = new Parser(init);

init = parser.result;
if (baseURL) {
if (typeof baseURL === "string") {
init.baseURL = baseURL;
} else {
throw new TypeError(`'baseURL' parameter is not of type 'string'.`);
}
} else if (typeof init.protocol !== "string") {
if (baseURL === void 0 && typeof init.protocol !== "string") {
throw new TypeError(`A base URL must be provided for a relative constructor string.`);
}
} else if (baseURL) {
throw new TypeError(`parameter 1 is not of type 'string'.`);
init.baseURL = baseURL;
} else {
if (!init || typeof init !== "object") {
throw new TypeError(`parameter 1 is not of type 'string' and cannot convert to dictionary.`);
}
if (baseURL) {
throw new TypeError(`parameter 1 is not of type 'string'.`);
}
}
if (!init || typeof init !== "object") {
throw new TypeError(`parameter 1 is not of type 'string' and cannot convert to dictionary.`);
if (typeof options === "undefined") {
options = { ignoreCase: false };
}
const ignoreCaseOptions = { ignoreCase: options.ignoreCase === true };
const defaults = {

@@ -1040,3 +1047,3 @@ pathname: DEFAULT_PATTERN,

continue;
const options = {};
const options2 = {};
const pattern = this.pattern[component];

@@ -1046,47 +1053,47 @@ this.keys[component] = [];

case "protocol":
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = protocolEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS);
options2.encodePart = protocolEncodeCallback;
break;
case "username":
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = usernameEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS);
options2.encodePart = usernameEncodeCallback;
break;
case "password":
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = passwordEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS);
options2.encodePart = passwordEncodeCallback;
break;
case "hostname":
Object.assign(options, HOSTNAME_OPTIONS);
Object.assign(options2, HOSTNAME_OPTIONS);
if (treatAsIPv6Hostname(pattern)) {
options.encodePart = ipv6HostnameEncodeCallback;
options2.encodePart = ipv6HostnameEncodeCallback;
} else {
options.encodePart = hostnameEncodeCallback;
options2.encodePart = hostnameEncodeCallback;
}
break;
case "port":
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = portEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS);
options2.encodePart = portEncodeCallback;
break;
case "pathname":
if (isSpecialScheme(this.regexp.protocol)) {
Object.assign(options, PATHNAME_OPTIONS);
options.encodePart = standardURLPathnameEncodeCallback;
Object.assign(options2, PATHNAME_OPTIONS, ignoreCaseOptions);
options2.encodePart = standardURLPathnameEncodeCallback;
} else {
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = pathURLPathnameEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS, ignoreCaseOptions);
options2.encodePart = pathURLPathnameEncodeCallback;
}
break;
case "search":
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = searchEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS, ignoreCaseOptions);
options2.encodePart = searchEncodeCallback;
break;
case "hash":
Object.assign(options, DEFAULT_OPTIONS);
options.encodePart = hashEncodeCallback;
Object.assign(options2, DEFAULT_OPTIONS, ignoreCaseOptions);
options2.encodePart = hashEncodeCallback;
break;
}
try {
const tokens = parse(pattern, options);
this.regexp[component] = tokensToRegexp(tokens, this.keys[component], options);
this.component_pattern[component] = tokensToPattern(tokens, options);
const tokens = parse(pattern, options2);
this.regexp[component] = tokensToRegexp(tokens, this.keys[component], options2);
this.component_pattern[component] = tokensToPattern(tokens, options2);
} catch {

@@ -1127,3 +1134,3 @@ throw new TypeError(`invalid ${component} pattern '${this.pattern[component]}'.`);

let component;
for (component in this.pattern) {
for (component of COMPONENTS) {
if (!this.regexp[component].exec(values[component])) {

@@ -1168,3 +1175,3 @@ return false;

let component;
for (component in this.pattern) {
for (component of COMPONENTS) {
let match = this.regexp[component].exec(values[component]);

@@ -1171,0 +1178,0 @@ if (!match) {

{
"name": "urlpattern-polyfill",
"version": "5.0.9",
"version": "6.0.1",
"description": "Polyfill for the URLPattern API",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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