UrlEncoded String, Decode UriComponent

UrlEncoded String, Decode UriComponent

UrlEncoded String, Decode UriComponent
Decodes a URL-encoded string that is an encoded component of a Uniform Resource Identifier. “5%25off%3F” will be decoded to “5%off?” and “%E3%81%82%20%E3%81%84” will be decoded to “あ い”.
Configs
  • A1: Set URL-encoded String (eg “5%25off%3F” ) *#{EL}
  • B1: Select STRING that stores Decoded String (update) *
Script (click to open)
// GraalJS Script (engine type: 2)

//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
const strEncoded       = configs.get( "StrConfA1" );          // REQUIRED
  if( strEncoded     === "" ){
    engine.log( " AutomatedTask ConfigWarning:" +
                " Config {A1: URL-Encoded String} is empty \n" );
  }
const strPocketDecoded = configs.getObject( "SelectConfB1" ); // REQUIRED


//// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)


//// == Calculating / 演算 ==
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
let strDecoded = decodeURIComponent( strEncoded );


//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketDecoded, strDecoded );

} //////// END "main()" /////////////////////////////////////////////////////////////////



/*
Notes:
- Many characters are URL-encoded in the URI.
    - The exceptions: A-Z a-z 0-9 - _ . ! ~ * ' ( )
- For application/x-www-form-urlencoded, spaces are to be replaced by +
    - But decodeURIComponent () does not replace "+" with a space.
    - "%20" will be decoded into a space.

Notes-ja:
- URI 部では、多くの文字が URL エンコード(エスケープ)されます。
    - 例外: A-Z a-z 0-9 - _ . ! ~ * ' ( )
- application/x-www-form-urlencoded では、スペースは + に置換されます。
    - しかし decodeURIComponent() は "+" をスペースに置換しません。
    - "%20" はスペースにデコードされます。
*/

/*
APPENDIX
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI

APPENDIX-ja
- https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
- https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/decodeURI
*/

Download

2021-04-03 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/urlencoded-string-decode-uricomponent/
The Addon-import feature is available with Professional edition.

Notes

  • Many characters in the URI section are URL-encoded.
    • The exceptions: A-Z a-z 0-9 – _ . ! ~ * ‘ ( )
  • For application/x-www-form-urlencoded, spaces are to be replaced by +
    • But decodeURIComponent () does not replace “+” with a space.
    • “%20” will be decoded into a space.

Capture

Decodes URL-encoded string that is an encoded component of a Uniform Resource Identifier. "5%25off%3F" will be decoded to "5%off?" and "%E3%81%82%20%E3%81%84" will be decoded to "あ い".

Appendix

See also

1 thought on “UrlEncoded String, Decode UriComponent”

  1. Pingback: URL String, Extract Parts – Questetra Support

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading