(url, cbKey)
| 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 |
no test coverage detected