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

Configure Feed

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

internal/routing/sanitizer: use strings.CutPrefix and SplitSeq

Aly Raffauf (Jul 5, 2026, 12:11 PM EDT) a8c6443c 502c3a22

+4 -6
+4 -6
internal/routing/sanitizer.go
··· 56 56 } 57 57 58 58 rule := adGuardRule{} 59 - if strings.HasPrefix(line, "@@") { 59 + if rest, ok := strings.CutPrefix(line, "@@"); ok { 60 60 rule.isException = true 61 - line = line[2:] 61 + line = rest 62 62 } 63 63 64 64 parts := strings.Split(line, "$") ··· 75 75 } 76 76 77 77 if len(parts) > 1 { 78 - options := strings.Split(parts[1], ",") 79 - for _, opt := range options { 80 - if strings.HasPrefix(opt, "removeparam=") { 81 - paramValue := strings.TrimPrefix(opt, "removeparam=") 78 + for opt := range strings.SplitSeq(parts[1], ",") { 79 + if paramValue, ok := strings.CutPrefix(opt, "removeparam="); ok { 82 80 if strings.HasPrefix(paramValue, "/") && strings.HasSuffix(paramValue, "/") { 83 81 if re, err := regexp.Compile("(?i)" + paramValue[1:len(paramValue)-1]); err == nil { 84 82 rule.parameterRegex = re