MCPcopy Create free account
hub / github.com/ampproject/amphtml / queryParametersToObject

Function queryParametersToObject

ads/vendors/fusion.js:7–18  ·  view source on GitHub ↗

* @param {string=} input * @return {JsonObject|undefined}

(input)

Source from the content-addressed store, hash-verified

5 * @return {JsonObject|undefined}
6 */
7function queryParametersToObject(input) {
8 if (!input) {
9 return undefined;
10 }
11 return input
12 .split('&')
13 .filter(Boolean)
14 .reduce((obj, val) => {
15 const kv = val.split('=');
16 return Object.assign(obj, {[kv[0]]: kv[1] || true});
17 }, {});
18}
19
20/**
21 * @param {!Window} global

Callers 1

fusionFunction · 0.85

Calls 2

assignMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected