New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

resource-path

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resource-path - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

34

dist/resourcePath.js

@@ -45,17 +45,19 @@ 'use strict';

*/
function resource(uri, params = {}) {
const PROTOCOL_AND_IPV6_REGEX = /^https?:\/\/\[[^\]]*][^/]*/;
function resource(uri) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let url = uri;
const urlParams = {};
let encodedVal;
let protocolAndIpv6 = '';
var PROTOCOL_AND_IPV6_REGEX = /^https?:\/\/\[[^\]]*][^/]*/;
url.split(/\W/).forEach(param => {
var url = uri;
var urlParams = {};
var encodedVal = void 0;
var protocolAndIpv6 = '';
url.split(/\W/).forEach(function (param) {
if (param === 'hasOwnProperty') {
throw Error('badname', 'hasOwnProperty is not a valid parameter name.');
}
if (!new RegExp('^\\d+$').test(param) && param && new RegExp(`(^|[^\\\\]):${param}(\\W|$)`).test(url)) {
if (!new RegExp('^\\d+$').test(param) && param && new RegExp('(^|[^\\\\]):' + param + '(\\W|$)').test(url)) {
urlParams[param] = {
isQueryParamValue: new RegExp(`\\?.*=:${param}(?:\\W|$)`).test(url)
isQueryParamValue: new RegExp('\\?.*=:' + param + '(?:\\W|$)').test(url)
};

@@ -66,3 +68,3 @@ }

url = url.replace(/\\:/g, ':');
url = url.replace(PROTOCOL_AND_IPV6_REGEX, match => {
url = url.replace(PROTOCOL_AND_IPV6_REGEX, function (match) {
protocolAndIpv6 = match;

@@ -72,5 +74,5 @@ return '';

Object.keys(urlParams).forEach(urlParam => {
const val = params[urlParam];
const paramInfo = urlParams[urlParam];
Object.keys(urlParams).forEach(function (urlParam) {
var val = params[urlParam];
var paramInfo = urlParams[urlParam];
if (typeof val !== 'undefined' && val !== null) {

@@ -82,5 +84,7 @@ if (paramInfo.isQueryParamValue) {

}
url = url.replace(new RegExp(`:${urlParam}(\\W|$)`, 'g'), (match, p1) => encodedVal + p1);
url = url.replace(new RegExp(':' + urlParam + '(\\W|$)', 'g'), function (match, p1) {
return encodedVal + p1;
});
} else {
url = url.replace(new RegExp(`(/?):${urlParam}(\\W|$)`, 'g'), (match, leadingSlashes, tail) => {
url = url.replace(new RegExp('(/?):' + urlParam + '(\\W|$)', 'g'), function (match, leadingSlashes, tail) {
if (tail.charAt(0) === '/') {

@@ -87,0 +91,0 @@ return tail;

{
"name": "resource-path",
"version": "1.3.0",
"version": "1.4.0",
"description": "Tiny module to generate resource paths for APIs",

@@ -45,5 +45,5 @@ "main": "index.js",

"presets": [
"@ava/stage-4"
"es2015"
]
}
}

Sorry, the diff of this file is not supported yet

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