Skip to content

Commit

Permalink
Add querystring.unescapeBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Nov 18, 2010
1 parent 57d8172 commit 6ff12c4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function charCode (c) {


// a safe fast alternative to decodeURIComponent
QueryString.unescape = function (s, decodeSpaces) {
QueryString.unescapeBuffer = function (s, decodeSpaces) {
var out = new Buffer(s.length);
var state = "CHAR"; // states: CHAR, HEX0, HEX1
var n, m, hexchar;
Expand Down Expand Up @@ -72,7 +72,12 @@ QueryString.unescape = function (s, decodeSpaces) {

// TODO support returning arbitrary buffers.

return out.toString('utf8', 0, outIndex-1);
return out.slice(0, outIndex-1);
};


QueryString.unescape = function (s, decodeSpaces) {
return QueryString.unescapeBuffer(s, decodeSpaces).toString();
};


Expand Down

0 comments on commit 6ff12c4

Please sign in to comment.