(url?: string)
| 3 | * Provides a standardized set of headers for all outward network requests. |
| 4 | */ |
| 5 | export function getCommonHeaders(url?: string) { |
| 6 | const headers: Record<string, string> = { |
| 7 | "User-Agent": |
| 8 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", |
| 9 | Accept: "*/*", |
| 10 | "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", |
| 11 | Connection: "keep-alive" |
| 12 | }; |
| 13 | |
| 14 | if (url) { |
| 15 | try { |
| 16 | const urlObj = new URL(url); |
| 17 | headers["Referer"] = urlObj.origin; |
| 18 | } catch (e) { |
| 19 | // Ignore invalid URL |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | return headers; |
| 24 | } |
no outgoing calls
no test coverage detected