Last active
July 14, 2017 18:26
-
-
Save Dev1an/2ae27273cd06bf82b0ccf032fa188eec to your computer and use it in GitHub Desktop.
Decode/Encode WAMP URI's
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
| function encode(string) { | |
| return string.replace(/[\x20\x23\x25\x2e]/g, (character, offset) => "%" + string.charCodeAt(offset).toString(16)) | |
| } | |
| function decode(string) { | |
| return string.replace(/%(20|23|25|2e|2E)/g, (character, hex) => String.fromCharCode(parseInt(hex, 16))) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment