UNPKG

@textback/notification-widget

Version:

TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.

34 lines (30 loc) 1.03 kB
function parseQueryString(query) { const vars = query.split('&'), queryString = {}; if (query.length > 0) { for (var i = 0; i < vars.length; i++) { const pair = vars[i].split('='), key = decodeURIComponent(pair[0]), value = decodeURIComponent(pair[1]); if (!key) continue; switch ( typeof queryString[key] ) { // If first entry with this name case 'undefined': queryString[key] = value; break; // If second entry with this name case 'string': { const arr = [ queryString[key], value ]; queryString[ key ] = arr; break; } // If third or later entry with this name default: queryString[key].push(value); } } } return queryString; } export default parseQueryString;