diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-03-10 20:40:35 +0100 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-03-10 20:40:35 +0100 |
commit | ac15678dea78248c0a293a1d1d677bef96d60127 (patch) | |
tree | 30813b9397fc2918e8cef9e76654eb2a845a6373 /js/utils | |
parent | 3d6212378aeaed4ce2f4ffd070b79cecf221977e (diff) | |
download | fosdem-2021-minimalism-presentation-ac15678dea78248c0a293a1d1d677bef96d60127.tar fosdem-2021-minimalism-presentation-ac15678dea78248c0a293a1d1d677bef96d60127.tar.gz |
refactoring
Diffstat (limited to 'js/utils')
-rw-r--r-- | js/utils/util.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/utils/util.js b/js/utils/util.js index 868f02b..b96578f 100644 --- a/js/utils/util.js +++ b/js/utils/util.js @@ -158,4 +158,30 @@ export const createStyleSheet = ( value ) => { return tag; +} + +/** + * Returns a key:value hash of all query params. + */ +export const getQueryHash = () => { + + let query = {}; + + location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, a => { + query[ a.split( '=' ).shift() ] = a.split( '=' ).pop(); + } ); + + // Basic deserialization + for( let i in query ) { + let value = query[ i ]; + + query[ i ] = deserialize( unescape( value ) ); + } + + // Do not accept new dependencies via query config to avoid + // the potential of malicious script injection + if( typeof query['dependencies'] !== 'undefined' ) delete query['dependencies']; + + return query; + }
\ No newline at end of file |