Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

test: add edge cases for globMatch URL pattern matching

okwnabf361517a52
diff --git a/internal/bridge/route_glob_test.go b/internal/bridge/route_glob_test.go
new file mode 100644
index 00000000..47d8f897
--- /dev/null
+++ b/internal/bridge/route_glob_test.go
@@ -0,0 +1,33 @@
+package bridge
+
+import (
+ "testing"
+)
+
+func TestGlobMatch_EdgeCases(t *testing.T) {
+ cases := []struct {
+ name string
+ pattern string
+ url string
+ want bool
+ }{
+ {"empty pattern returns false", "", "https://anything.test/", false},
+ {"empty URL returns false", "api.example.com", "", false},
+ {"both empty returns false", "", "", false},
+ {"unicode in URL", "café.example.com", "https://café.example.com/", true},
+ {"unicode in pattern", "*.example.com", "https://café.example.com/", false}, // non-ASCII not matched by glob
+ {"query string preserved", "api.example.com", "https://api.example.com?foo=bar", true},
+ {"fragment preserved", "api.example.com", "https://api.example.com#/path", true},
+ {"port in URL", "api.example.com", "https://api.example.com:8080/users", true},
+ {"IP address literal", "127.0.0.1", "https://127.0.0.1/api", true},
+ {"https vs http", "http://api.example.com", "https://api.example.com", false},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ got := globMatch(tc.pattern, tc.url)
+ if got != tc.want {
+ t.Errorf("globMatch(%q, %q) = %v, want %v", tc.pattern, tc.url, got, tc.want)
+ }
+ })
+ }
+}
\ No newline at end of file