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.

main: avoid duplication with prepareURLForRouting helper

Aly Raffauf (Jul 1, 2026, 8:13 AM EDT) a29bdd98 652c8083

+19 -19
+19 -19
src/main.go
··· 60 60 return 61 61 } 62 62 63 - sanitized := sanitizeURL(rawURL) 63 + sanitized := prepareURLForRouting(rawURL, cfg) 64 64 if sanitized == "" { 65 65 // URL was rejected (mailto:, tel:, etc.) - pass to xdg-open 66 66 cmd := hostCommand("xdg-open", rawURL) 67 67 cmd.Start() 68 68 return 69 - } 70 - 71 - if cfg.RemoveTrackingParameters { 72 - sanitized = removeTrackingParameters(sanitized) 73 - } 74 - 75 - if len(cfg.Redirections) > 0 { 76 - sanitized = applyRedirections(sanitized, cfg.Redirections) 77 69 } 78 70 79 71 handleURL(app, browsers, cfg, sanitized) ··· 112 104 return 113 105 } 114 106 115 - // Sanitize the target URL 116 - sanitized := sanitizeURL(targetURL) 107 + sanitized := prepareURLForRouting(targetURL, cfg) 117 108 if sanitized == "" { 118 109 // Pass non-browser URLs to xdg-open 119 110 cmd := hostCommand("xdg-open", targetURL) ··· 121 112 return 122 113 } 123 114 124 - if cfg.RemoveTrackingParameters { 125 - sanitized = removeTrackingParameters(sanitized) 126 - } 127 - 128 - if len(cfg.Redirections) > 0 { 129 - sanitized = applyRedirections(sanitized, cfg.Redirections) 130 - } 131 - 132 115 // If browser preferences specified, try each in order 133 116 if len(browserPrefs) > 0 { 134 117 for _, pref := range browserPrefs { ··· 149 132 150 133 // No browser specified - use standard routing 151 134 handleURL(app, browsers, cfg, sanitized) 135 + } 136 + 137 + func prepareURLForRouting(rawURL string, cfg *Config) string { 138 + sanitized := sanitizeURL(rawURL) 139 + if sanitized == "" { 140 + return "" 141 + } 142 + 143 + if cfg.RemoveTrackingParameters { 144 + sanitized = removeTrackingParameters(sanitized) 145 + } 146 + 147 + if len(cfg.Redirections) > 0 { 148 + sanitized = applyRedirections(sanitized, cfg.Redirections) 149 + } 150 + 151 + return sanitized 152 152 } 153 153 154 154 // handleURL routes a URL to the appropriate browser based on rules