* change root dit and change way to import modules * update deps to latest versions * use latest tools for building bundles * rewrite webpack config * use nomodule technique for loading modern bundle * inject polyfills by babel usebuiltins * update eslint rules * rename all style files to CSS * use postcss preset env for building styles * proper typescript typing * put all html files to templates folder * etc
19 lines
439 B
TypeScript
19 lines
439 B
TypeScript
/** converts widnow.location.search into object */
|
|
export default function parseQuery<T extends {}>(search: string = window.location.search): T {
|
|
if (search.length < 2) {
|
|
return {} as T;
|
|
}
|
|
|
|
return search
|
|
.substr(1)
|
|
.split('&')
|
|
.reduce((accum, param) => {
|
|
const [key, value] = param.split('=');
|
|
|
|
return {
|
|
...accum,
|
|
[key]: value ? decodeURIComponent(value) : '',
|
|
};
|
|
}, {} as T);
|
|
}
|