| 405 | * @returns an object with args, command, options and urlSearch |
| 406 | */ |
| 407 | export function constructOpenOptions(platform: NodeJS.Platform | "wsl", urlSearch: string): OpenOptions { |
| 408 | const args: string[] = [] |
| 409 | let command = platform === "darwin" ? "open" : "xdg-open" |
| 410 | if (platform === "win32" || platform === "wsl") { |
| 411 | command = platform === "wsl" ? "cmd.exe" : "cmd" |
| 412 | args.push("/c", "start", '""', "/b") |
| 413 | urlSearch = urlSearch.replace(/&/g, "^&") |
| 414 | } |
| 415 | |
| 416 | return { |
| 417 | args, |
| 418 | command, |
| 419 | urlSearch, |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * Try opening an address using whatever the system has set for opening URLs. |