MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / sanitizeJsonpCallbackParam

Function sanitizeJsonpCallbackParam

lib/test/angular/1.6.7/angular.js:12659–12681  ·  view source on GitHub ↗
(url, cbKey)

Source from the content-addressed store, hash-verified

12657 }
12658
12659 function sanitizeJsonpCallbackParam(url, cbKey) {
12660 var parts = url.split('?');
12661 if (parts.length > 2) {
12662 // Throw if the url contains more than one `?` query indicator
12663 throw $httpMinErr('badjsonp', 'Illegal use more than one "?", in url, "{1}"', url);
12664 }
12665 var params = parseKeyValue(parts[1]);
12666 forEach(params, function(value, key) {
12667 if (value === 'JSON_CALLBACK') {
12668 // Throw if the url already contains a reference to JSON_CALLBACK
12669 throw $httpMinErr('badjsonp', 'Illegal use of JSON_CALLBACK in url, "{0}"', url);
12670 }
12671 if (key === cbKey) {
12672 // Throw if the callback param was already provided
12673 throw $httpMinErr('badjsonp', 'Illegal use of callback param, "{0}", in url, "{1}"', cbKey, url);
12674 }
12675 });
12676
12677 // Add in the JSON_CALLBACK callback param value
12678 url += ((url.indexOf('?') === -1) ? '?' : '&') + cbKey + '=JSON_CALLBACK';
12679
12680 return url;
12681 }
12682 }];
12683}
12684

Callers 1

sendReqFunction · 0.70

Calls 2

parseKeyValueFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected