default-browser
Advanced tools
+1
-1
| { | ||
| "name": "default-browser", | ||
| "version": "5.4.0", | ||
| "version": "5.5.0", | ||
| "description": "Get the default browser", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+8
-5
@@ -48,8 +48,11 @@ import {promisify} from 'node:util'; | ||
| const browser = windowsBrowserProgIds[id]; | ||
| if (!browser) { | ||
| throw new UnknownBrowserError(`Unknown browser ID: ${id}`); | ||
| } | ||
| // Windows can append a hash suffix to ProgIds using a dot or hyphen | ||
| // (e.g., `ChromeHTML.ABC123`, `FirefoxURL-6F193CCC56814779`). | ||
| // Try exact match first, then try without the suffix. | ||
| const dotIndex = id.lastIndexOf('.'); | ||
| const hyphenIndex = id.lastIndexOf('-'); | ||
| const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex); | ||
| const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex); | ||
| return browser; | ||
| return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {name: id, id}; | ||
| } |
6871
6.46%98
3.16%