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/ ...@@ -62,6 +62,7 @@ MIT License, see http://mit-license.org/
Release Notes 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.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.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) * 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 () { ...@@ -181,7 +181,7 @@ var pctEncoder = (function () {
index; index;
for (index = 0; index < octets.length; index += 1) { for (index = 0; index < octets.length; index += 1) {
octet = octets.charCodeAt(index); octet = octets.charCodeAt(index);
result += '%' + octet.toString(16).toUpperCase(); result += '%' + (octet < 0x10 ? '0' : '') + octet.toString(16).toUpperCase();
} }
return result; return result;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"template", "template",
"rfc6570" "rfc6570"
], ],
"author": "Franz Antesberger", "author": "Franz X Antesberger",
"contributors": [], "contributors": [],
"dependencies": {}, "dependencies": {},
"main": "bin/uritemplate.js", "main": "bin/uritemplate.js",
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"uritemplate-test/spec-examples-by-sections.json", "uritemplate-test/spec-examples-by-sections.json",
"uritemplate-test/spec-examples.json" "uritemplate-test/spec-examples.json"
], ],
"version": "0.3.2", "version": "0.3.3",
"readmeFilename": "README.md", "readmeFilename": "README.md",
"gitHead": "901b85201a821427dfb4591b56aea3a70d45c67c", "gitHead": "901b85201a821427dfb4591b56aea3a70d45c67c",
"devDependencies": { "devDependencies": {
......
...@@ -41,7 +41,7 @@ var pctEncoder = (function () { ...@@ -41,7 +41,7 @@ var pctEncoder = (function () {
index; index;
for (index = 0; index < octets.length; index += 1) { for (index = 0; index < octets.length; index += 1) {
octet = octets.charCodeAt(index); octet = octets.charCodeAt(index);
result += '%' + octet.toString(16).toUpperCase(); result += '%' + (octet < 0x10 ? '0' : '') + octet.toString(16).toUpperCase();
} }
return result; return result;
} }
......
...@@ -61,6 +61,10 @@ module.exports = (function () { ...@@ -61,6 +61,10 @@ module.exports = (function () {
test.equal(pctEncoder.encodeCharacter('y'), '%79'); test.equal(pctEncoder.encodeCharacter('y'), '%79');
test.equal(pctEncoder.encodeCharacter('!'), '%21'); test.equal(pctEncoder.encodeCharacter('!'), '%21');
test.done(); 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