Skip to content

Commit 9d04bee

Browse files
🐛 Fix open URL in Firefox (#7)
1 parent b6bcabd commit 9d04bee

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

browsers/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ def launch(browser: str, url: str, args: Optional[Sequence[str]] = None) -> None
104104
if not b:
105105
logger.info("Cannot find browser '%s'", browser)
106106
return
107-
_launch(b["path"], url, args)
107+
_launch(browser, b["path"], url, args)
108108

109109

110-
def _launch(path: str, url: str, args: Sequence[str]) -> None: # pragma: no cover
111-
command = [*shlex.split(path), url, "--args", *args]
110+
def _launch(browser: str, path: str, url: str, args: Sequence[str]) -> None: # pragma: no cover
111+
url_arg = [] if browser == "firefox" else [url]
112+
if browser == "firefox":
113+
args = ("-new-tab", url, *args)
114+
command = [*shlex.split(path), *url_arg, "--args", *args]
112115
if sys.platform == "darwin":
113116
command = ["open", "--wait-apps", "--new", "--fresh", "-a", *command]
114117
subprocess.Popen(command)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pybrowsers"
3-
version = "0.1.0-alpha.3"
3+
version = "0.1.0-alpha.4"
44
repository = "https://github.com/roniemartinez/browsers"
55
description = "Python library for detecting and launching browsers"
66
authors = ["Ronie Martinez <ronmarti18@gmail.com>"]

tests/test_detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_get(browser: str, details: Dict) -> None:
114114
@mock.patch.object(browsers, "_launch")
115115
def test_launch(mock_launch: mock.MagicMock, chrome_path: str) -> None:
116116
browsers.launch("chrome", url="https://github.com/roniemartinez/browsers")
117-
mock_launch.assert_called_with(chrome_path, "https://github.com/roniemartinez/browsers", [])
117+
mock_launch.assert_called_with("chrome", chrome_path, "https://github.com/roniemartinez/browsers", [])
118118

119119

120120
@mock.patch.object(browsers, "_launch")

0 commit comments

Comments
 (0)