| 47 | const isOk = (status, validate) => (validate ? validate(status) : status >= 200 && status < 300); |
| 48 | |
| 49 | const wrapNetworkError = (error) => { |
| 50 | if (error.name === 'TimeoutError' || error.name === 'AbortError') { |
| 51 | const e = new Error(error.message || 'Request timed out'); |
| 52 | e.code = 'ECONNABORTED'; |
| 53 | return e; |
| 54 | } |
| 55 | const code = error.cause?.code; |
| 56 | if (code) { |
| 57 | const e = new Error(error.message); |
| 58 | e.code = code; |
| 59 | return e; |
| 60 | } |
| 61 | return error; |
| 62 | }; |
| 63 | |
| 64 | const UA = 'web-check/1.0 (https://web-check.xyz)'; |
| 65 | |