Skip to content

Instantly share code, notes, and snippets.

@ralphholzmann
Created May 25, 2011 14:32
Show Gist options
  • Save ralphholzmann/991080 to your computer and use it in GitHub Desktop.
Save ralphholzmann/991080 to your computer and use it in GitHub Desktop.
encodeURIComponent doesn't follow rfc3986 that oauth requires. This is my fix...
var oauthPercentEncode = (function(){
var escapeChars = "!*'();:@&=+$,/?%#[]",
matchChars = new RegExp( "([\\" + ( escapeChars.split('').join('\\')) + "])", "gi");
return function( p ) {
return p.replace( matchChars, function( char ) {
return '%' + ( "" + char ).charCodeAt(0).toString(16).toUpperCase();
})
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment