From 4db1ee53efc7481b689ebee69b5381d63fe59419 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Dec 2020 02:49:54 +0100 Subject: Handle `%s` format string for URL in `BROWSER` variable The `BROWSER` environment variable might contain a `%s` format string that should be replaced by the URL to open. If it's present perform the replacement. Otherwise, append the URL to the `BROWSER` command as before. --- browserenv_unix_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'browserenv_unix_test.go') diff --git a/browserenv_unix_test.go b/browserenv_unix_test.go index 35af81c..f49444e 100644 --- a/browserenv_unix_test.go +++ b/browserenv_unix_test.go @@ -21,6 +21,18 @@ func TestBrowserCommand(t *testing.T) { "https://duckduckgo.com", "open -a Firefox 'https://duckduckgo.com'", }, + { + "with URL directive at end", + "open -a Firefox %s", + "https://duckduckgo.com", + "open -a Firefox https://duckduckgo.com", + }, + { + "with URL directive in middle", + "open -a Firefox %s --other-arg", + "https://duckduckgo.com", + "open -a Firefox https://duckduckgo.com --other-arg", + }, } for _, test := range tests { -- cgit v1.2.3