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

Function sanitizeJsonpCallbackParam

test/angular/1.6/angular.js:12815–12837  ·  view source on GitHub ↗
(url, cbKey)

Source from the content-addressed store, hash-verified

12813 }
12814
12815 function sanitizeJsonpCallbackParam(url, cbKey) {
12816 var parts = url.split('?');
12817 if (parts.length > 2) {
12818 // Throw if the url contains more than one `?` query indicator
12819 throw $httpMinErr('badjsonp', 'Illegal use more than one "?", in url, "{1}"', url);
12820 }
12821 var params = parseKeyValue(parts[1]);
12822 forEach(params, function(value, key) {
12823 if (value === 'JSON_CALLBACK') {
12824 // Throw if the url already contains a reference to JSON_CALLBACK
12825 throw $httpMinErr('badjsonp', 'Illegal use of JSON_CALLBACK in url, "{0}"', url);
12826 }
12827 if (key === cbKey) {
12828 // Throw if the callback param was already provided
12829 throw $httpMinErr('badjsonp', 'Illegal use of callback param, "{0}", in url, "{1}"', cbKey, url);
12830 }
12831 });
12832
12833 // Add in the JSON_CALLBACK callback param value
12834 url += ((url.indexOf('?') === -1) ? '?' : '&') + cbKey + '=JSON_CALLBACK';
12835
12836 return url;
12837 }
12838 }];
12839}
12840

Callers 1

sendReqFunction · 0.70

Calls 2

parseKeyValueFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected