(path: string)
| 35 | export function createHostUtils() { |
| 36 | return { |
| 37 | readFile(path: string): string { |
| 38 | const ctx = readFileStorage.getStore(); |
| 39 | if (ctx?.readFile) { |
| 40 | const relative = stripWorkingDir(path, ctx.workingDir); |
| 41 | if (relative != null) { |
| 42 | const result = ctx.readFile(relative); |
| 43 | if (result != null) return result; |
| 44 | } |
| 45 | } |
| 46 | // No readFile callback or it returned null -- do not fall through to |
| 47 | // readFileSync because the WASM module could request arbitrary host |
| 48 | // paths (e.g. via `-r /etc/passwd` in requirements.txt). |
| 49 | throw new WitResultError(`File not found: ${path}`); |
| 50 | }, |
| 51 | domainToAscii(domain: string): string { |
| 52 | try { |
| 53 | // Use the WHATWG URL parser for IDNA2008 conversion. |
no test coverage detected