(url, destination, corsAttributeState, sameOriginFallback)
| 26 | } |
| 27 | |
| 28 | function createPotentialCORSRequest (url, destination, corsAttributeState, sameOriginFallback) { |
| 29 | // 1. Let mode be "no-cors" if corsAttributeState is No CORS, and "cors" otherwise. |
| 30 | let mode = corsAttributeState === 'no cors' ? 'no-cors' : 'cors' |
| 31 | |
| 32 | // 2. If same-origin fallback flag is set and mode is "no-cors", set mode to "same-origin". |
| 33 | if (sameOriginFallback && mode === 'no-cors') { |
| 34 | mode = 'same-origin' |
| 35 | } |
| 36 | |
| 37 | // 3. Let credentialsMode be "include". |
| 38 | let credentialsMode = 'include' |
| 39 | |
| 40 | // 4. If corsAttributeState is Anonymous, set credentialsMode to "same-origin". |
| 41 | if (corsAttributeState === 'anonymous') { |
| 42 | credentialsMode = 'same-origin' |
| 43 | } |
| 44 | |
| 45 | // 5. Return a new request whose URL is url, destination is destination, mode is mode, |
| 46 | // credentials mode is credentialsMode, and whose use-URL-credentials flag is set. |
| 47 | return makeRequest({ |
| 48 | urlList: [url], |
| 49 | destination, |
| 50 | mode, |
| 51 | credentials: credentialsMode, |
| 52 | useCredentials: true |
| 53 | }) |
| 54 | } |
| 55 | |
| 56 | module.exports = { |
| 57 | isValidLastEventId, |
no test coverage detected