1function getAllUrlParams(url) { 2 let queryString = url ? url.split('?')[1] : window.location.search.slice(1); 3 const obj = {}; 4 if (queryString) { 5 // stuff after # is not part of query string, so get rid of it 6 queryString = queryString.split('#')[0]; 7 // split our query string into its component parts 8 const arr = queryString.split('&'); 9 for (let i = 0; i < arr.length; i++) { 10 // separate the keys and the values 11 const a = arr[i].split('='); 12 // set parameter name and value (use 'true' if empty) 13 let paramName = a[0]; 14 let paramValue = typeof a[1] === 'undefined' ? true : a[1]; 15 // (optional) keep case consistent 16 paramName = paramName.toLowerCase(); 17 if (typeof paramValue === 'string') paramValue = paramValue.toLowerCase(); 18 // if the paramName ends with square brackets, e.g. colors[] or colors[2] 19 if (paramName.match(/\[(\d+)?\]$/)) { 20 // create key if it doesn't exist 21 const key = paramName.replace(/\[(\d+)?\]/, ''); 22 if (!obj[key]) obj[key] = []; 23 // if it's an indexed array e.g. colors[2] 24 if (paramName.match(/\[\d+\]$/)) { 25 // get the index value and add the entry at the appropriate position 26 const index = /\[(\d+)\]/.exec(paramName)[1]; 27 obj[key][index] = paramValue; 28 } else { 29 // otherwise add the value to the end of the array 30 obj[key].push(paramValue); 31 } 32 } else { 33 // we're dealing with a string 34 if (!obj[paramName]) { 35 // if it doesn't exist, create property 36 obj[paramName] = paramValue; 37 } else if (obj[paramName] && typeof obj[paramName] === 'string') { 38 // if property does exist and it's a string, convert it to an array 39 obj[paramName] = [obj[paramName]]; 40 obj[paramName].push(paramValue); 41 } else { 42 // otherwise add the property 43 obj[paramName].push(paramValue); 44 } 45 } 46 } 47 } 48 49 return obj; 50}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.