MCPcopy
hub / github.com/angular-ui/ui-router / sanitizeJsonpCallbackParam

Function sanitizeJsonpCallbackParam

test/angular/1.7/angular.js:13386–13408  ·  view source on GitHub ↗
(url, cbKey)

Source from the content-addressed store, hash-verified

13384 }
13385
13386 function sanitizeJsonpCallbackParam(url, cbKey) {
13387 var parts = url.split('?');
13388 if (parts.length > 2) {
13389 // Throw if the url contains more than one `?` query indicator
13390 throw $httpMinErr('badjsonp', 'Illegal use more than one "?", in url, "{1}"', url);
13391 }
13392 var params = parseKeyValue(parts[1]);
13393 forEach(params, function(value, key) {
13394 if (value === 'JSON_CALLBACK') {
13395 // Throw if the url already contains a reference to JSON_CALLBACK
13396 throw $httpMinErr('badjsonp', 'Illegal use of JSON_CALLBACK in url, "{0}"', url);
13397 }
13398 if (key === cbKey) {
13399 // Throw if the callback param was already provided
13400 throw $httpMinErr('badjsonp', 'Illegal use of callback param, "{0}", in url, "{1}"', cbKey, url);
13401 }
13402 });
13403
13404 // Add in the JSON_CALLBACK callback param value
13405 url += ((url.indexOf('?') === -1) ? '?' : '&') + cbKey + '=JSON_CALLBACK';
13406
13407 return url;
13408 }
13409 }];
13410}
13411

Callers 1

sendReqFunction · 0.70

Calls 2

parseKeyValueFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected