(url, cbKey)
| 13449 | } |
| 13450 | |
| 13451 | function sanitizeJsonpCallbackParam(url, cbKey) { |
| 13452 | var parts = url.split('?'); |
| 13453 | if (parts.length > 2) { |
| 13454 | // Throw if the url contains more than one `?` query indicator |
| 13455 | throw $httpMinErr('badjsonp', 'Illegal use more than one "?", in url, "{1}"', url); |
| 13456 | } |
| 13457 | var params = parseKeyValue(parts[1]); |
| 13458 | forEach(params, function(value, key) { |
| 13459 | if (value === 'JSON_CALLBACK') { |
| 13460 | // Throw if the url already contains a reference to JSON_CALLBACK |
| 13461 | throw $httpMinErr('badjsonp', 'Illegal use of JSON_CALLBACK in url, "{0}"', url); |
| 13462 | } |
| 13463 | if (key === cbKey) { |
| 13464 | // Throw if the callback param was already provided |
| 13465 | throw $httpMinErr('badjsonp', 'Illegal use of callback param, "{0}", in url, "{1}"', cbKey, url); |
| 13466 | } |
| 13467 | }); |
| 13468 | |
| 13469 | // Add in the JSON_CALLBACK callback param value |
| 13470 | url += ((url.indexOf('?') === -1) ? '?' : '&') + cbKey + '=JSON_CALLBACK'; |
| 13471 | |
| 13472 | return url; |
| 13473 | } |
| 13474 | }]; |
| 13475 | } |
| 13476 |
no test coverage detected