Commit aa35786f authored by fxa's avatar fxa

Pct-Encoding-Error with chars < 0x100 (missing 0-padding). Thanks to https://github.com/pfraze!

parent 19aa9f17
......@@ -62,6 +62,7 @@ MIT License, see http://mit-license.org/
Release Notes
-------------
* 0.3.3 fixed https://github.com/fxa/uritemplate-js/issues/12 Pct-Encoding-Error with chars < 0x100 (missing 0-padding). Thanks to https://github.com/pfraze!
* 0.3.2 fixed https://github.com/fxa/uritemplate-js/issues/11 Problems with older IE versions. Thanks to anozaki!
* 0.3.1 fixed https://github.com/fxa/uritemplate-js/issues/10 thank you, Paul-Martin!
* 0.3.0 introduced UriTemplateError as exception, so the interface changed from string to UriTemplateError (as the rfc suggested)
......
This diff is collapsed.
......@@ -181,7 +181,7 @@ var pctEncoder = (function () {
index;
for (index = 0; index < octets.length; index += 1) {
octet = octets.charCodeAt(index);
result += '%' + octet.toString(16).toUpperCase();
result += '%' + (octet < 0x10 ? '0' : '') + octet.toString(16).toUpperCase();
}
return result;
}
......
......@@ -8,7 +8,7 @@
"template",
"rfc6570"
],
"author": "Franz Antesberger",
"author": "Franz X Antesberger",
"contributors": [],
"dependencies": {},
"main": "bin/uritemplate.js",
......@@ -33,7 +33,7 @@
"uritemplate-test/spec-examples-by-sections.json",
"uritemplate-test/spec-examples.json"
],
"version": "0.3.2",
"version": "0.3.3",
"readmeFilename": "README.md",
"gitHead": "901b85201a821427dfb4591b56aea3a70d45c67c",
"devDependencies": {
......
......@@ -41,7 +41,7 @@ var pctEncoder = (function () {
index;
for (index = 0; index < octets.length; index += 1) {
octet = octets.charCodeAt(index);
result += '%' + octet.toString(16).toUpperCase();
result += '%' + (octet < 0x10 ? '0' : '') + octet.toString(16).toUpperCase();
}
return result;
}
......
......@@ -61,6 +61,10 @@ module.exports = (function () {
test.equal(pctEncoder.encodeCharacter('y'), '%79');
test.equal(pctEncoder.encodeCharacter('!'), '%21');
test.done();
},
'encoding is always padded': function (test) {
test.equal(pctEncoder.encodeCharacter('\n'), '%0A');
test.done();
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment