(options: { allowPrivateIp: boolean })
| 119 | * function always dereferences `globalThis.fetch` lazily so tests that replace |
| 120 | * the global see their replacement. */ |
| 121 | export function createWebhookFetch(options: { allowPrivateIp: boolean }): typeof fetch { |
| 122 | return async (input, init) => { |
| 123 | if (!options.allowPrivateIp) { |
| 124 | const href = typeof input === 'string' || input instanceof URL |
| 125 | ? input.toString() |
| 126 | : input.url; |
| 127 | await assertPublicTarget(new URL(href)); |
| 128 | } |
| 129 | return globalThis.fetch(input, init); |
| 130 | }; |
| 131 | } |
no test coverage detected