MCPcopy Create free account
hub / github.com/angular-ui/ui-router / extractParamsFromQuery

Function extractParamsFromQuery

test/angular/1.7/angular-mocks.js:2243–2264  ·  view source on GitHub ↗
(queryStr)

Source from the content-addressed store, hash-verified

2241 }
2242
2243 function extractParamsFromQuery(queryStr) {
2244 var obj = {},
2245 keyValuePairs = queryStr.split('&').
2246 filter(angular.identity). // Ignore empty segments.
2247 map(function(keyValue) { return keyValue.replace(/\+/g, '%20').split('='); });
2248
2249 angular.forEach(keyValuePairs, function(pair) {
2250 var key = tryDecodeURIComponent(pair[0]);
2251 if (angular.isDefined(key)) {
2252 var val = angular.isDefined(pair[1]) ? tryDecodeURIComponent(pair[1]) : true;
2253 if (!hasOwnProperty.call(obj, key)) {
2254 obj[key] = val;
2255 } else if (angular.isArray(obj[key])) {
2256 obj[key].push(val);
2257 } else {
2258 obj[key] = [obj[key], val];
2259 }
2260 }
2261 });
2262
2263 return obj;
2264 }
2265
2266 function tryDecodeURIComponent(value) {
2267 try {

Callers 1

MockHttpExpectationFunction · 0.85

Calls 1

tryDecodeURIComponentFunction · 0.70

Tested by

no test coverage detected