MCPcopy Index your code
hub / github.com/ampproject/amphtml / parseQueryString

Function parseQueryString

examples/pwa/pwa.js:481–507  ·  view source on GitHub ↗

* Parses the query string of an URL. This method returns a simple key/value * map. If there are duplicate keys the latest value is returned. * @param {string} queryString * @return {!Object }

(queryString)

Source from the content-addressed store, hash-verified

479 * @return {!Object<string>}
480 */
481function parseQueryString(queryString) {
482 const params = Object.create(null);
483 if (!queryString) {
484 return params;
485 }
486 if (startsWith(queryString, '?') || startsWith(queryString, '#')) {
487 queryString = queryString.substr(1);
488 }
489 const pairs = queryString.split('&');
490 for (let i = 0; i < pairs.length; i++) {
491 const pair = pairs[i];
492 const eqIndex = pair.indexOf('=');
493 let name;
494 let value;
495 if (eqIndex != -1) {
496 name = decodeURIComponent(pair.substring(0, eqIndex)).trim();
497 value = decodeURIComponent(pair.substring(eqIndex + 1)).trim();
498 } else {
499 name = decodeURIComponent(pair).trim();
500 value = '';
501 }
502 if (name) {
503 params[name] = value;
504 }
505 }
506 return params;
507}
508
509var shell = new Shell(window, /* useStreaming */ true); // eslint-disable-line @typescript-eslint/no-unused-vars

Callers 1

constructorMethod · 0.70

Calls 2

startsWithFunction · 0.70
createMethod · 0.45

Tested by

no test coverage detected