Skip to content

Instantly share code, notes, and snippets.

@Dev1an
Last active July 14, 2017 18:26
Show Gist options
  • Select an option

  • Save Dev1an/2ae27273cd06bf82b0ccf032fa188eec to your computer and use it in GitHub Desktop.

Select an option

Save Dev1an/2ae27273cd06bf82b0ccf032fa188eec to your computer and use it in GitHub Desktop.
Decode/Encode WAMP URI's
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