MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / parseKeyValue

Function parseKeyValue

OpenReservation/wwwroot/Scripts/angular.js:1329–1355  ·  view source on GitHub ↗

* Parses an escaped url query string into key-value pairs. * @returns {Object. }

(/**string*/keyValue)

Source from the content-addressed store, hash-verified

1327 * @returns {Object.<string,boolean|Array>}
1328 */
1329 function parseKeyValue(/**string*/keyValue) {
1330 var obj = {};
1331 forEach((keyValue || "").split('&'),
1332 function (keyValue) {
1333 var splitPoint, key, val;
1334 if (keyValue) {
1335 key = keyValue = keyValue.replace(/\+/g, '%20');
1336 splitPoint = keyValue.indexOf('=');
1337 if (splitPoint !== -1) {
1338 key = keyValue.substring(0, splitPoint);
1339 val = keyValue.substring(splitPoint + 1);
1340 }
1341 key = tryDecodeURIComponent(key);
1342 if (isDefined(key)) {
1343 val = isDefined(val) ? tryDecodeURIComponent(val) : true;
1344 if (!hasOwnProperty.call(obj, key)) {
1345 obj[key] = val;
1346 } else if (isArray(obj[key])) {
1347 obj[key].push(val);
1348 } else {
1349 obj[key] = [obj[key], val];
1350 }
1351 }
1352 }
1353 });
1354 return obj;
1355 }
1356
1357 function toKeyValue(obj) {
1358 var parts = [];

Callers 2

parseAppUrlFunction · 0.85
angular.jsFile · 0.85

Calls 3

forEachFunction · 0.85
tryDecodeURIComponentFunction · 0.85
isDefinedFunction · 0.85

Tested by

no test coverage detected