@@ -580,6 +580,110 @@ const functions = (() => {
580580 return atob ( str ) ;
581581 }
582582
583+ /**
584+ * Encode a string into a component for a url
585+ * @param {String } str - String to encode
586+ * @returns {string } Encoded string
587+ */
588+ function encodeUrlComponent ( str ) {
589+ // undefined inputs always return undefined
590+ if ( typeof str === 'undefined' ) {
591+ return undefined ;
592+ }
593+
594+ // Catch URIErrors when URI sequence is malformed
595+ var returnVal ;
596+ try {
597+ returnVal = encodeURIComponent ( str ) ;
598+ } catch ( e ) {
599+ throw {
600+ code : "D3140" ,
601+ stack : ( new Error ( ) ) . stack ,
602+ value : str ,
603+ functionName : "encodeUrlComponent"
604+ } ;
605+ }
606+ return returnVal ;
607+ }
608+
609+ /**
610+ * Encode a string into a url
611+ * @param {String } str - String to encode
612+ * @returns {string } Encoded string
613+ */
614+ function encodeUrl ( str ) {
615+ // undefined inputs always return undefined
616+ if ( typeof str === 'undefined' ) {
617+ return undefined ;
618+ }
619+
620+ // Catch URIErrors when URI sequence is malformed
621+ var returnVal ;
622+ try {
623+ returnVal = encodeURI ( str ) ;
624+ } catch ( e ) {
625+ throw {
626+ code : "D3140" ,
627+ stack : ( new Error ( ) ) . stack ,
628+ value : str ,
629+ functionName : "encodeUrl"
630+ } ;
631+ }
632+ return returnVal ;
633+ }
634+
635+ /**
636+ * Decode a string from a component for a url
637+ * @param {String } str - String to decode
638+ * @returns {string } Decoded string
639+ */
640+ function decodeUrlComponent ( str ) {
641+ // undefined inputs always return undefined
642+ if ( typeof str === 'undefined' ) {
643+ return undefined ;
644+ }
645+
646+ // Catch URIErrors when URI sequence is malformed
647+ var returnVal ;
648+ try {
649+ returnVal = decodeURIComponent ( str ) ;
650+ } catch ( e ) {
651+ throw {
652+ code : "D3140" ,
653+ stack : ( new Error ( ) ) . stack ,
654+ value : str ,
655+ functionName : "decodeUrlComponent"
656+ } ;
657+ }
658+ return returnVal ;
659+ }
660+
661+ /**
662+ * Decode a string from a url
663+ * @param {String } str - String to decode
664+ * @returns {string } Decoded string
665+ */
666+ function decodeUrl ( str ) {
667+ // undefined inputs always return undefined
668+ if ( typeof str === 'undefined' ) {
669+ return undefined ;
670+ }
671+
672+ // Catch URIErrors when URI sequence is malformed
673+ var returnVal ;
674+ try {
675+ returnVal = decodeURI ( str ) ;
676+ } catch ( e ) {
677+ throw {
678+ code : "D3140" ,
679+ stack : ( new Error ( ) ) . stack ,
680+ value : str ,
681+ functionName : "decodeUrl"
682+ } ;
683+ }
684+ return returnVal ;
685+ }
686+
583687 /**
584688 * Split a string into an array of substrings
585689 * @param {String } str - string
@@ -1844,7 +1948,7 @@ const functions = (() => {
18441948 boolean, not,
18451949 map, zip, filter, single, foldLeft, sift,
18461950 keys, lookup, append, exists, spread, merge, reverse, each, error, sort, shuffle,
1847- base64encode, base64decode
1951+ base64encode, base64decode, encodeUrlComponent , encodeUrl , decodeUrlComponent , decodeUrl
18481952 } ;
18491953} ) ( ) ;
18501954
0 commit comments