Socket
Socket
Sign inDemoInstall

@xo-union/url-template

Package Overview
Dependencies
0
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.6 to 3.0.0-uep1.beta.1

lib/index.cjs

44

lib/index.js

@@ -1,39 +0,19 @@

import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/esm/classPrivateFieldGet";
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/esm/classPrivateFieldSet";
import _WeakMap from "@babel/runtime-corejs3/core-js/weak-map";
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
import { parse, format } from "url";
var _templateString = /*#__PURE__*/new _WeakMap();
var _variables = /*#__PURE__*/new _WeakMap();
var _replacer = /*#__PURE__*/new _WeakMap();
export default class UrlTemplate {
#templateString;
#variables;
constructor(templateString, variables) {
_classPrivateFieldInitSpec(this, _templateString, {
writable: true,
value: void 0
});
_classPrivateFieldInitSpec(this, _variables, {
writable: true,
value: void 0
});
_classPrivateFieldInitSpec(this, _replacer, {
writable: true,
value: (_match, capture) => {
if (Object.prototype.hasOwnProperty.call(_classPrivateFieldGet(this, _variables), capture)) {
return _classPrivateFieldGet(this, _variables)[capture];
}
throw new Error(`Unspecified template variable: ${capture}`);
}
});
_classPrivateFieldSet(this, _templateString, templateString);
_classPrivateFieldSet(this, _variables, variables);
this.#templateString = templateString;
this.#variables = variables;
}
#replacer = (_match, capture) => {
if (Object.prototype.hasOwnProperty.call(this.#variables, capture)) {
return this.#variables[capture].toString().replace(/^\/+|\/+$/g, '');
}
throw new Error(`Unspecified template variable: ${capture}`);
};
set(key, value) {
_classPrivateFieldGet(this, _variables)[key] = value;
this.#variables[key] = value;
}
toString() {
const url = parse(_classPrivateFieldGet(this, _templateString));
url.pathname = decodeURIComponent(url.pathname || '').replace(/\{([A-Za-z_$]+)\}/g, _classPrivateFieldGet(this, _replacer)).replace(/\/{2,}/g, '/');
return format(url);
return this.#templateString.replace(/\{([A-Za-z_$]+)\}/g, this.#replacer);
}

@@ -40,0 +20,0 @@ toJSON() {

{
"name": "@xo-union/url-template",
"version": "2.0.6",
"version": "3.0.0-uep1.beta.1",
"sideEffects": false,
"main": "lib/index.cjs.js",
"main": "lib/index.cjs",
"module": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"__source": "./src/index.ts",
"module": "./lib/index.js",
"import": "./lib/index.mjs",
"require": "./lib/index.cjs",
"types": "./lib/index.d.ts"
}
},
"browserslist": "extends @xo-union/browserslist-config",
"scripts": {
"build.code": "union-packager-build --preset ts",
"build.types": "tsc",
"build.pkg": "yarn build.code && yarn build.types",
"validate.pkg": "union-pkg-validator"
"build.code": "feps-build-code",
"build.types": "feps-build-types",
"build.pkg": "feps-build-pkg",
"validate.pkg": "package-lint"
},
"dependencies": {
"@babel/runtime-corejs3": "^7.22.5"
},
"devDependencies": {
"@xo-union/packager": "^6.1.5",
"@xo-union/pkg-validator": "^3.2.3"
"@tkww/fep-scripts": "^0.0.1-0-uep1.beta.1",
"@tkww/orion-web-package-lint": "^1.0.0-uep1.beta.1"
},

@@ -31,3 +38,4 @@ "files": [

},
"gitHead": "a1bd6754ae5d2d9a1f0c3d7d417a09769e516db6"
}
"$schema": "../../../shared-configs/schemas/package-json-schema.json",
"stableVersion": "2.0.6"
}
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