* 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)
| 479 | * @return {!Object<string>} |
| 480 | */ |
| 481 | function 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 | |
| 509 | var shell = new Shell(window, /* useStreaming */ true); // eslint-disable-line @typescript-eslint/no-unused-vars |
no test coverage detected