Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

default-browser

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

default-browser - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

23

index.js

@@ -0,11 +1,22 @@

import {promisify} from 'node:util';
import process from 'node:process';
import {execFile} from 'node:child_process';
import defaultBrowserId from 'default-browser-id';
import bundleName from 'bundle-name';
import titleize from 'titleize';
import {execa} from 'execa';
import windows from './windows.js';
const execFileAsync = promisify(execFile);
// Inlined: https://github.com/sindresorhus/titleize/blob/main/index.js
const titleize = string => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, x => x.toUpperCase());
export default async function defaultBrowser() {
if (process.platform === 'darwin') {
const id = await defaultBrowserId();
const name = await bundleName(id);
return {name, id};
}
if (process.platform === 'linux') {
const {stdout} = await execa('xdg-mime', ['query', 'default', 'x-scheme-handler/http']);
const {stdout} = await execFileAsync('xdg-mime', ['query', 'default', 'x-scheme-handler/http']);
const name = titleize(stdout.trim().replace(/.desktop$/, '').replace('-', ' '));

@@ -19,8 +30,2 @@

if (process.platform === 'darwin') {
const id = await defaultBrowserId();
const name = await bundleName(id);
return {name, id};
}
if (process.platform === 'win32') {

@@ -27,0 +32,0 @@ return windows();

{
"name": "default-browser",
"version": "5.1.0",
"version": "5.2.0",
"description": "Get the default browser",

@@ -18,2 +18,3 @@ "license": "MIT",

},
"sideEffects": false,
"engines": {

@@ -46,12 +47,10 @@ "node": ">=18"

"dependencies": {
"bundle-name": "^4.0.0",
"default-browser-id": "^4.0.0",
"execa": "^8.0.1",
"titleize": "^4.0.0"
"bundle-name": "^4.1.0",
"default-browser-id": "^5.0.0"
},
"devDependencies": {
"ava": "^5.3.1",
"tsd": "^0.29.0",
"ava": "^6.0.1",
"tsd": "^0.30.0",
"xo": "^0.56.0"
}
}

@@ -1,3 +0,6 @@

import {execa} from 'execa';
import {promisify} from 'node:util';
import {execFile} from 'node:child_process';
const execFileAsync = promisify(execFile);
// Windows doesn't have browser IDs in the same way macOS/Linux does so we give fake

@@ -19,4 +22,4 @@ // ones that look real and match the macOS/Linux versions for cross-platform apps.

export default async function defaultBrowser(_execa = execa) {
const result = await _execa('reg', [
export default async function defaultBrowser(_execFileAsync = execFileAsync) {
const {stdout} = await _execFileAsync('reg', [
'QUERY',

@@ -28,5 +31,5 @@ ' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',

const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(result.stdout);
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
if (!match) {
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(result.stdout)}`);
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
}

@@ -33,0 +36,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc