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

url-template

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-template - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7

25

lib/url-template.js

@@ -24,3 +24,3 @@ (function (root, factory) {

if (!/%[0-9A-Fa-f]/.test(part)) {
part = encodeURI(part);
part = encodeURI(part).replace(/%5B/g, '[').replace(/%5D/g, ']');
}

@@ -33,2 +33,13 @@ return part;

* @private
* @param {string} str
* @return {string}
*/
UrlTemplate.prototype.encodeUnreserved = function (str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
});
}
/**
* @private
* @param {string} operator

@@ -40,6 +51,6 @@ * @param {string} value

UrlTemplate.prototype.encodeValue = function (operator, value, key) {
value = (operator === '+' || operator === '#') ? this.encodeReserved(value) : encodeURIComponent(value);
value = (operator === '+' || operator === '#') ? this.encodeReserved(value) : this.encodeUnreserved(value);
if (key) {
return encodeURIComponent(key) + '=' + value;
return this.encodeUnreserved(key) + '=' + value;
} else {

@@ -111,3 +122,3 @@ return value;

if (this.isDefined(value[k])) {
tmp.push(encodeURIComponent(k));
tmp.push(this.encodeUnreserved(k));
tmp.push(this.encodeValue(operator, value[k].toString()));

@@ -119,3 +130,3 @@ }

if (this.isKeyOperator(operator)) {
result.push(encodeURIComponent(key) + '=' + tmp.join(','));
result.push(this.encodeUnreserved(key) + '=' + tmp.join(','));
} else if (tmp.length !== 0) {

@@ -128,5 +139,5 @@ result.push(tmp.join(','));

if (operator === ';') {
result.push(encodeURIComponent(key));
result.push(this.encodeUnreserved(key));
} else if (value === '' && (operator === '&' || operator === '?')) {
result.push(encodeURIComponent(key) + '=');
result.push(this.encodeUnreserved(key) + '=');
} else if (value === '') {

@@ -133,0 +144,0 @@ result.push('');

{
"name": "url-template",
"version": "2.0.6",
"decription": "A URI template implementation (RFC 6570 compliant)",
"author": "Bram Stein <b.l.stein@gmail.com> (http://www.bramstein.com)",
"keywords": ["uri-template", "uri template", "uri", "url", "rfc 6570", "url template", "url-template"],
"devDependencies": {
"mocha": "=1.6.0",
"expect.js": "=0.2.0"
},
"license": "BSD",
"repository": {
"type": "git",
"url": "git://github.com/bramstein/url-template.git"
},
"main": "./lib/url-template.js",
"directories": {
"lib": "./lib"
},
"scripts": {
"test": "mocha --reporter spec"
}
"name": "url-template",
"version": "2.0.7",
"decription": "A URI template implementation (RFC 6570 compliant)",
"author": "Bram Stein <b.l.stein@gmail.com> (http://www.bramstein.com)",
"keywords": [
"uri-template",
"uri template",
"uri",
"url",
"rfc 6570",
"url template",
"url-template"
],
"devDependencies": {
"mocha": "=1.6.0",
"expect.js": "=0.2.0"
},
"license": "BSD",
"repository": {
"type": "git",
"url": "git://github.com/bramstein/url-template.git"
},
"main": "./lib/url-template.js",
"directories": {
"lib": "./lib"
},
"scripts": {
"test": "mocha --reporter spec"
}
}

@@ -43,3 +43,3 @@ var template, expect;

assert('Hello World!/{foo}', 'Hello%20World!/bar');
assert(':/?#[]@!$&()*+,;=\'', ':/?#%5B%5D@!$&()*+,;=\'');
assert(':/?#[]@!$&()*+,;=\'', ':/?#[]@!$&()*+,;=\'');
assert('%20', '%20');

@@ -91,3 +91,3 @@ assert('%xyz', '%25xyz');

it('escape invalid characters correctly', function () {
assert('{hello}', 'Hello%20World!');
assert('{hello}', 'Hello%20World%21');
});

@@ -126,3 +126,3 @@ });

assert('map?{x,y}', 'map?1024,768');
assert('{x,hello,y}', '1024,Hello%20World!,768');
assert('{x,hello,y}', '1024,Hello%20World%21,768');
});

@@ -313,8 +313,10 @@

it('encodes restricted characters correctly', function () {
assert('{restricted}', '%3A%2F%3F%23%5B%5D%40!%24%26()*%2B%2C%3B%3D\'');
assert('{/restricted}', '/%3A%2F%3F%23%5B%5D%40!%24%26()*%2B%2C%3B%3D\'');
assert('{;restricted}', ';restricted=%3A%2F%3F%23%5B%5D%40!%24%26()*%2B%2C%3B%3D\'');
assert('{.restricted}', '.%3A%2F%3F%23%5B%5D%40!%24%26()*%2B%2C%3B%3D\'');
assert('{?restricted}', '?restricted=%3A%2F%3F%23%5B%5D%40!%24%26()*%2B%2C%3B%3D\'');
assert('{&restricted}', '&restricted=%3A%2F%3F%23%5B%5D%40!%24%26()*%2B%2C%3B%3D\'');
assert('{restricted}', '%3A%2F%3F%23%5B%5D%40%21%24%26%28%29%2A%2B%2C%3B%3D%27');
assert('{+restricted}', ':/?#[]@!$&()*+,;=\'');
assert('{#restricted}', '#:/?#[]@!$&()*+,;=\'');
assert('{/restricted}', '/%3A%2F%3F%23%5B%5D%40%21%24%26%28%29%2A%2B%2C%3B%3D%27');
assert('{;restricted}', ';restricted=%3A%2F%3F%23%5B%5D%40%21%24%26%28%29%2A%2B%2C%3B%3D%27');
assert('{.restricted}', '.%3A%2F%3F%23%5B%5D%40%21%24%26%28%29%2A%2B%2C%3B%3D%27');
assert('{?restricted}', '?restricted=%3A%2F%3F%23%5B%5D%40%21%24%26%28%29%2A%2B%2C%3B%3D%27');
assert('{&restricted}', '&restricted=%3A%2F%3F%23%5B%5D%40%21%24%26%28%29%2A%2B%2C%3B%3D%27');
});

@@ -321,0 +323,0 @@ });

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