package urlutil import ( "reflect" "testing" ) func TestExtractURLs(t *testing.T) { tests := []struct { name string text string expected []string }{ { name: "no URLs", text: "just some plain text with no links", expected: []string{}, }, { name: "single URL in text", text: "check this out https://example.com/photo it is cool", expected: []string{"https://example.com/photo"}, }, { name: "URL with trailing punctuation", text: "look at https://example.com/photo.", expected: []string{"https://example.com/photo"}, }, { name: "URL wrapped in parentheses", text: "see (https://example.com/a) for details", expected: []string{"https://example.com/a"}, }, { name: "multiple URLs", text: "https://a.com/1 and http://b.com/2", expected: []string{"https://a.com/1", "http://b.com/2"}, }, { name: "duplicate URLs are de-duplicated", text: "https://a.com/1 https://a.com/1", expected: []string{"https://a.com/1"}, }, { name: "command prefix stripped by extraction", text: "!gallerydl https://example.com/gallery/123", expected: []string{"https://example.com/gallery/123"}, }, { name: "non-http scheme ignored", text: "ftp://example.com/file and https://ok.com/x", expected: []string{"https://ok.com/x"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := ExtractURLs(tt.text) if !reflect.DeepEqual(got, tt.expected) { t.Errorf("ExtractURLs(%q) = %v, want %v", tt.text, got, tt.expected) } }) } }