(req: OriginValidationRequest, allowHttpOrigin = false)
| 318 | } |
| 319 | |
| 320 | function getExpectedOrigins(req: OriginValidationRequest, allowHttpOrigin = false): string[] { |
| 321 | const hosts = getExpectedHosts(req); |
| 322 | |
| 323 | if (hosts.length === 0) { |
| 324 | return []; |
| 325 | } |
| 326 | |
| 327 | const protocols = getExpectedProtocols(req, allowHttpOrigin); |
| 328 | |
| 329 | const expectedOrigins: string[] = []; |
| 330 | for (const protocol of protocols) { |
| 331 | for (const host of hosts) { |
| 332 | const origin = buildOrigin(protocol, host); |
| 333 | if (!origin || expectedOrigins.includes(origin)) { |
| 334 | continue; |
| 335 | } |
| 336 | |
| 337 | expectedOrigins.push(origin); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | return expectedOrigins; |
| 342 | } |
| 343 | |
| 344 | function normalizeOrigin(raw: string | null | undefined): string | null { |
| 345 | if (!raw) { |
no test coverage detected