Last active
June 30, 2020 07:10
-
-
Save admcfajn/2ed5d46b8ee96cbdd0b8d16f1be2f6f0 to your computer and use it in GitHub Desktop.
Build URL Object
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
| /* | |
| * Build URL Object | |
| * Returns dest: current url-base, sub_params_out: json-object with get-params as names & arrays built from csv-string | |
| **/ | |
| function build_url_object(){ | |
| let | |
| dest = window.location.origin + window.location.pathname, | |
| params = window.location.search.replace( '?', '' ), | |
| sub_params = null, | |
| sub_params_out = {}; | |
| if ( params.length ) { | |
| sub_params = params.split( '&' ); | |
| } | |
| if ( sub_params ) { | |
| for ( let i in sub_params ) { | |
| let item = sub_params[ i ].split( '=' ); | |
| sub_params_out[ item[ 0 ] ] = item[ 1 ].split( ',' ); | |
| } | |
| } | |
| return { 'dest': dest, 'sub_params_out': sub_params_out }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment