| 1 | const vscode = require("vscode"); |
| 2 | |
| 3 | // Authority of the handled uri must equal this extension's identifier |
| 4 | // (publisher.name); see package.json. Opening |
| 5 | // vscode://clover.simple-browser-bridge/open?url=<encodeURIComponent(url)> |
| 6 | // (e.g. via `code --open-url`, as the companion `open` shim does) shows the |
| 7 | // target in the built-in Simple Browser instead of the system browser. |
| 8 | function activate(context) { |
| 9 | context.subscriptions.push( |
| 10 | vscode.window.registerUriHandler({ |
| 11 | handleUri(uri) { |
| 12 | const url = new URLSearchParams(uri.query).get("url"); |
| 13 | if (url) { |
| 14 | vscode.commands.executeCommand("simpleBrowser.show", url); |
| 15 | } |
| 16 | }, |
| 17 | }), |
| 18 | ); |
| 19 | } |
| 20 | |
| 21 | function deactivate() {} |
| 22 | |
| 23 | module.exports = { activate, deactivate }; |