Socket
Socket
Sign inDemoInstall

path-parser

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-parser - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

coverage/lcov-report/base.css

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="1.0.4"></a>
## [1.0.4](https://github.com/troch/path-parser/compare/v1.0.3...v1.0.4) (2016-06-30)
### Bug Fixes
* encode all parameters and not only query parameters ([19d5131](https://github.com/troch/path-parser/commit/19d5131))
<a name="1.0.3"></a>

@@ -2,0 +12,0 @@ ## [1.0.3](https://github.com/troch/path-parser/compare/v1.0.2...v1.0.3) (2016-06-29)

21

dist/amd/path-parser.js

@@ -150,3 +150,3 @@ define('Path', function () { 'use strict';

var toSerialisable = function toSerialisable(val) {
return val !== undefined && val !== null && val !== '' ? '=' + encodeURIComponent(val) : '';
return val !== undefined && val !== null && val !== '' ? '=' + val : '';
};

@@ -310,2 +310,11 @@

var encodedParams = Object.keys(params).reduce(function (acc, key) {
// Use encodeURI in case of spats
if (params[key] === undefined) {
acc[key] = undefined;
} else {
acc[key] = Array.isArray(params[key]) ? params[key].map(encodeURI) : encodeURI(params[key]);
}
return acc;
}, {});
// Check all params are provided (not search parameters which are optional)

@@ -322,3 +331,3 @@ if (this.urlParams.some(function (p) {

}).every(function (t) {
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(params[t.val]);
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val]);
});

@@ -333,4 +342,4 @@

}).map(function (t) {
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + params[t.val[0]];
return (/^url-parameter/.test(t.type) ? params[t.val[0]] : t.match
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + encodedParams[t.val[0]];
return (/^url-parameter/.test(t.type) ? encodedParams[t.val[0]] : t.match
);

@@ -346,5 +355,5 @@ }).join('');

var searchPart = queryParams.filter(function (p) {
return Object.keys(params).indexOf(withoutBrackets(p)) !== -1;
return Object.keys(encodedParams).indexOf(withoutBrackets(p)) !== -1;
}).map(function (p) {
return _serialise(p, params[withoutBrackets(p)]);
return _serialise(p, encodedParams[withoutBrackets(p)]);
}).join('&');

@@ -351,0 +360,0 @@

@@ -132,3 +132,3 @@ 'use strict';

var toSerialisable = function toSerialisable(val) {
return val !== undefined && val !== null && val !== '' ? '=' + encodeURIComponent(val) : '';
return val !== undefined && val !== null && val !== '' ? '=' + val : '';
};

@@ -292,2 +292,11 @@

var encodedParams = Object.keys(params).reduce(function (acc, key) {
// Use encodeURI in case of spats
if (params[key] === undefined) {
acc[key] = undefined;
} else {
acc[key] = Array.isArray(params[key]) ? params[key].map(encodeURI) : encodeURI(params[key]);
}
return acc;
}, {});
// Check all params are provided (not search parameters which are optional)

@@ -304,3 +313,3 @@ if (this.urlParams.some(function (p) {

}).every(function (t) {
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(params[t.val]);
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val]);
});

@@ -315,4 +324,4 @@

}).map(function (t) {
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + params[t.val[0]];
return (/^url-parameter/.test(t.type) ? params[t.val[0]] : t.match
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + encodedParams[t.val[0]];
return (/^url-parameter/.test(t.type) ? encodedParams[t.val[0]] : t.match
);

@@ -328,5 +337,5 @@ }).join('');

var searchPart = queryParams.filter(function (p) {
return Object.keys(params).indexOf(withoutBrackets(p)) !== -1;
return Object.keys(encodedParams).indexOf(withoutBrackets(p)) !== -1;
}).map(function (p) {
return _serialise(p, params[withoutBrackets(p)]);
return _serialise(p, encodedParams[withoutBrackets(p)]);
}).join('&');

@@ -333,0 +342,0 @@

@@ -154,3 +154,3 @@ (function (global, factory) {

var toSerialisable = function toSerialisable(val) {
return val !== undefined && val !== null && val !== '' ? '=' + encodeURIComponent(val) : '';
return val !== undefined && val !== null && val !== '' ? '=' + val : '';
};

@@ -314,2 +314,11 @@

var encodedParams = Object.keys(params).reduce(function (acc, key) {
// Use encodeURI in case of spats
if (params[key] === undefined) {
acc[key] = undefined;
} else {
acc[key] = Array.isArray(params[key]) ? params[key].map(encodeURI) : encodeURI(params[key]);
}
return acc;
}, {});
// Check all params are provided (not search parameters which are optional)

@@ -326,3 +335,3 @@ if (this.urlParams.some(function (p) {

}).every(function (t) {
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(params[t.val]);
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val]);
});

@@ -337,4 +346,4 @@

}).map(function (t) {
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + params[t.val[0]];
return (/^url-parameter/.test(t.type) ? params[t.val[0]] : t.match
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + encodedParams[t.val[0]];
return (/^url-parameter/.test(t.type) ? encodedParams[t.val[0]] : t.match
);

@@ -350,5 +359,5 @@ }).join('');

var searchPart = queryParams.filter(function (p) {
return Object.keys(params).indexOf(withoutBrackets(p)) !== -1;
return Object.keys(encodedParams).indexOf(withoutBrackets(p)) !== -1;
}).map(function (p) {
return _serialise(p, params[withoutBrackets(p)]);
return _serialise(p, encodedParams[withoutBrackets(p)]);
}).join('&');

@@ -355,0 +364,0 @@

@@ -114,3 +114,3 @@ const defaultOrConstrained = (match) =>

const toSerialisable = val => val !== undefined && val !== null && val !== '' ? '=' + encodeURIComponent(val) : '';
const toSerialisable = val => val !== undefined && val !== null && val !== '' ? `=${val}` : '';

@@ -218,2 +218,16 @@ const serialise = (key, val) => Array.isArray(val) ? val.map(v => serialise(key, v)).join('&') : key + toSerialisable(val);

build(params = {}, opts = {ignoreConstraints: false, ignoreSearch: false}) {
const encodedParams = Object.keys(params).reduce(
(acc, key) => {
// Use encodeURI in case of spats
if (params[key] === undefined) {
acc[key] = undefined;
} else {
acc[key] = Array.isArray(params[key])
? params[key].map(encodeURI)
: encodeURI(params[key]);
}
return acc;
},
{}
);
// Check all params are provided (not search parameters which are optional)

@@ -226,3 +240,3 @@ if (this.urlParams.some(p => params[p] === undefined)) throw new Error('Missing parameters');

.filter(t => /^url-parameter/.test(t.type) && !/-splat$/.test(t.type))
.every(t => new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(params[t.val]));
.every(t => new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val]));

@@ -235,4 +249,4 @@ if (!constraintsPassed) throw new Error('Some parameters are of invalid format');

.map(t => {
if (t.type === 'url-parameter-matrix') return `;${t.val}=${params[t.val[0]]}`;
return /^url-parameter/.test(t.type) ? params[t.val[0]] : t.match;
if (t.type === 'url-parameter-matrix') return `;${t.val}=${encodedParams[t.val[0]]}`;
return /^url-parameter/.test(t.type) ? encodedParams[t.val[0]] : t.match;
})

@@ -246,4 +260,4 @@ .join('');

const searchPart = queryParams
.filter(p => Object.keys(params).indexOf(withoutBrackets(p)) !== -1)
.map(p => serialise(p, params[withoutBrackets(p)]))
.filter(p => Object.keys(encodedParams).indexOf(withoutBrackets(p)) !== -1)
.map(p => serialise(p, encodedParams[withoutBrackets(p)]))
.join('&');

@@ -250,0 +264,0 @@

{
"name": "path-parser",
"version": "1.0.3",
"version": "1.0.4",
"description": "A small utility to parse, match and generate paths",

@@ -9,3 +9,3 @@ "main": "dist/commonjs/path-parser.js",

"test": "mocha --compilers js:babel-core/register",
"test-cover": "istanbul cover _mocha",
"test-cover": "babel-node node_modules/.bin/isparta cover node_modules/.bin/_mocha",
"lint": "eslint modules/*.js",

@@ -50,3 +50,3 @@ "build:amd": "BABEL_ENV=rollup rollup -c rollup.config.js --format amd",

"eslint": "^1.10.3",
"istanbul": "^0.3.16",
"isparta": "~4.0.0",
"mkdirp": "^0.5.1",

@@ -53,0 +53,0 @@ "mocha": "^2.2.5",

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