From eab88cc138ae74ce38aa060267fe5dfc243f17fb Mon Sep 17 00:00:00 2001 From: Alexey Ryabov Date: Mon, 23 May 2022 20:04:39 +0300 Subject: [PATCH] Fix open in browser doesn't work in WSL On Linux, `x-default-browser` requires `xdg-utils` to be installed to determine a default browser. So it fails when it's not installed. However, in WSL, we still can open a browser without it. Now it fallbacks to `open` when `x-default-browser` fails which makes it work on WSL without `xdg-utils`. --- lib/core-server/src/utils/open-in-browser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core-server/src/utils/open-in-browser.ts b/lib/core-server/src/utils/open-in-browser.ts index daa5938b3f07..bf98fbf9dd48 100644 --- a/lib/core-server/src/utils/open-in-browser.ts +++ b/lib/core-server/src/utils/open-in-browser.ts @@ -7,7 +7,7 @@ import dedent from 'ts-dedent'; export function openInBrowser(address: string) { getDefaultBrowser(async (err: any, res: any) => { try { - if (res.isChrome || res.isChromium) { + if (res && (res.isChrome || res.isChromium)) { // We use betterOpn for Chrome because it is better at handling which chrome tab // or window the preview loads in. betterOpn(address);