( uri: string, proxyHost?: string, agentName?: string, workspaceName?: string, username?: string, )
| 93 | // openMaybePortForwardedURL tries to open the provided URI through the |
| 94 | // port-forwarded URL if it is localhost, otherwise opens it normally. |
| 95 | export const openMaybePortForwardedURL = ( |
| 96 | uri: string, |
| 97 | proxyHost?: string, |
| 98 | agentName?: string, |
| 99 | workspaceName?: string, |
| 100 | username?: string, |
| 101 | ) => { |
| 102 | const open = (uri: string) => { |
| 103 | // Copied from: https://github.com/xtermjs/xterm.js/blob/master/addons/xterm-addon-web-links/src/WebLinksAddon.ts#L23 |
| 104 | const newWindow = window.open(); |
| 105 | if (newWindow) { |
| 106 | try { |
| 107 | newWindow.opener = null; |
| 108 | } catch { |
| 109 | // no-op, Electron can throw |
| 110 | } |
| 111 | newWindow.location.href = uri; |
| 112 | } else { |
| 113 | console.warn("Opening link blocked as opener could not be cleared"); |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | if (!agentName || !workspaceName || !username || !proxyHost) { |
| 118 | open(uri); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | open(rewriteLocalhostURL(uri, proxyHost, agentName, workspaceName, username)); |
| 123 | }; |
| 124 | |
| 125 | export const saveWorkspaceListeningPortsProtocol = ( |
| 126 | workspaceID: string, |
no test coverage detected