Created
July 3, 2019 02:16
-
-
Save fazlurr/c1842aafa59f46ffca0a74c0c850128c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Decode URI Component safe to use with single % | |
* | |
* @param {string} s String to Decode | |
* @return {string} Decoded Result | |
* | |
* @see https://stackoverflow.com/a/54310080/5627904 | |
*/ | |
export const decodeURIComponentSafe = (s) => { | |
if (!s) return s; | |
return decodeURIComponent(s.replace(/%(?![0-9][0-9a-fA-F]+)/g, '%25')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment