Rules-based browser launcher for TUI + GNOME. switchyard.aly.codes
tui gome bowser go
0

Configure Feed

Select the types of activity you want to include in your feed.

browser/launch: handle epty url

Aly Raffauf (Jul 5, 2026, 9:11 PM EDT) b82b5116 ea4f2b5f

+17 -1
+17 -1
internal/browser/launch.go
··· 31 31 // buildCommand assembles the OS command that launches cmdline for url, or nil 32 32 // when the resolved command line is empty. 33 33 func buildCommand(cmdline, url, activationToken string, inFlatpak bool) *exec.Cmd { 34 - cmdline = desktopexec.SubstituteOrAppendURL(cmdline, url) 34 + if url != "" { 35 + cmdline = desktopexec.SubstituteOrAppendURL(cmdline, url) 36 + } else { 37 + // Strip field codes. Shell-quoting an empty URL produces "''", 38 + // which most browsers open as file:///. 39 + cmdline = stripDesktopFieldCodes(cmdline) 40 + } 35 41 if strings.TrimSpace(cmdline) == "" { 36 42 return nil 37 43 } ··· 49 55 } 50 56 return cmd 51 57 } 58 + 59 + // stripDesktopFieldCodes removes desktop field codes without shell-quoting. 60 + // SubstituteURL would produce "''" for an empty URL, which most browsers 61 + // interpret as file:///. 62 + func stripDesktopFieldCodes(cmdline string) string { 63 + for _, code := range []string{"%u", "%U", "%f", "%F", "%i", "%c", "%k"} { 64 + cmdline = strings.ReplaceAll(cmdline, code, "") 65 + } 66 + return cmdline 67 + }