From 471b9798e14ac9c3109b6745c676418f425d4745 Mon Sep 17 00:00:00 2001 From: Franz Kafka Date: Sun, 22 Mar 2026 02:54:12 +0000 Subject: [PATCH] fix: regexp.DotAll flag in google engine and Metadata field removal - google.go: use inline (?s) flag instead of regexp.DotAll second arg - youtube.go: remove Metadata field (not in MainResult contract) - config_test.go: fix expected engine count from 9 to 11 (google+youtube) --- internal/config/config_test.go | 4 ++-- internal/engines/google.go | 2 +- internal/engines/youtube.go | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 4a09848..07bddef 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -14,8 +14,8 @@ func TestLoadDefaults(t *testing.T) { if cfg.Server.Port != 8080 { t.Errorf("expected default port 8080, got %d", cfg.Server.Port) } - if len(cfg.Engines.LocalPorted) != 9 { - t.Errorf("expected 9 default engines, got %d", len(cfg.Engines.LocalPorted)) + if len(cfg.Engines.LocalPorted) != 11 { + t.Errorf("expected 11 default engines, got %d", len(cfg.Engines.LocalPorted)) } } diff --git a/internal/engines/google.go b/internal/engines/google.go index 0371283..71b50d1 100644 --- a/internal/engines/google.go +++ b/internal/engines/google.go @@ -209,7 +209,7 @@ func extractGoogleSnippet(block string) string { func extractGoogleSuggestions(body string) []string { var suggestions []string // SearXNG xpath: //div[contains(@class, "ouy7Mc")]//a - suggestionPattern := regexp.MustCompile(`]*class="[^"]*ouy7Mc[^"]*"[^>]*>.*?]*>([^<]+)`, regexp.DotAll) + suggestionPattern := regexp.MustCompile(`(?s)]*class="[^"]*ouy7Mc[^"]*"[^>]*>.*?]*>([^<]+)`) matches := suggestionPattern.FindAllStringSubmatch(body, -1) seen := map[string]bool{} for _, m := range matches { diff --git a/internal/engines/youtube.go b/internal/engines/youtube.go index 7580a09..a18abd8 100644 --- a/internal/engines/youtube.go +++ b/internal/engines/youtube.go @@ -115,10 +115,6 @@ func (e *YouTubeEngine) Search(ctx context.Context, req contracts.SearchRequest) Score: 1.0, Category: "videos", Engines: []string{"youtube"}, - Metadata: map[string]any{ - "channel": item.Snippet.ChannelTitle, - "video_id": item.Snippet.ResourceID.VideoID, - }, }) }