Bug with `encodeKey` and `encodeValue`
See original GitHub issueencodeValue
looks like this (https://github.com/lpinca/shopify-token/blob/master/index.js#L7-L29)
function encodeValue(input) {
return input.replace(/&/g, '%26').replace(/%/g, '%25');
}
If input
was '&'
, it would return '%2526'
– the %
from the first replace
is replaced again in the 2nd one.
Is there a reason not to use use encodeURIComponent
?
Or perhaps,
input.replace(/[&%]/g, function(c) { return encodeURIComponent(c); })
?
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
[BUG] TypeScript Angular Escape colon · Issue #3372 - GitHub
[BUG] TypeScript Angular Escape colon #3372 ... Bug Report Checklist ... encodeKey(k); return k.replace(/\+/gi, '%2B'); } encodeValue(v: string): string { v ...
Read more >Angular url plus sign converting to space - Stack Overflow
This ia a common problem. The + character is used by the URL to separate two words. In order to use the +...
Read more >Comment #5 : Bug #945176 : Bugs : txAWS - Launchpad Bugs
Comment 5 for bug 945176. Revision history for this message ... result.append("%s=%s" % (self.encode(key), self.encode(value)))
Read more >Issue 8603: Create a bytes version of os.environ and getenvb()
A view comments on the patch: + def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv): As general ...
Read more >Angular Url Encode - StackBlitz
encodeValue (param);. } jsEncode(param: string){. return encodeURIComponent(param);. } ngDecode(param: string){. return this.codec.decodeValue(this.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jamiemtdwyer thanks.
shopify-token
does the same thing, see https://github.com/lpinca/shopify-token/blob/0ce4668c9c13a7b8db854966b8665d783255c6a7/index.js#L7-L29 and https://github.com/lpinca/shopify-token/blob/0ce4668c9c13a7b8db854966b8665d783255c6a7/index.js#L113.Hey guys,
Jamie from Shopify here. I would recommend taking a look at the strategy used in our official OAuth gem for Ruby:
https://github.com/Shopify/omniauth-shopify-oauth2/blob/master/lib/omniauth/strategies/shopify.rb#L67
We replace
&=%
in keys and&%
in values with their respective URI-encoded values.Cheers!