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

Function sanitizeJsonpCallbackParam

lib/test/angular/1.7.0/angular.js:12817–12839  ·  view source on GitHub ↗
(url, cbKey)

Source from the content-addressed store, hash-verified

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

Callers 1

sendReqFunction · 0.70

Calls 2

parseKeyValueFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected