Skip to content

Commit

Permalink
Exclude /results from channel resolver (#616)
Browse files Browse the repository at this point in the history
* Exclude /results from channel resolver

* Add changelog entry
  • Loading branch information
M4tthewDE authored Apr 3, 2024
1 parent d43279b commit 9b8acaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Minor: Add playlist support to YouTube resolver. (#597, #601)
- Fix: Do not resolve /results using YouTube channel resolver (#616)

## 2.0.3

Expand Down
4 changes: 4 additions & 0 deletions internal/resolvers/youtube/channel_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func (r *YouTubeChannelResolver) Check(ctx context.Context, url *url.URL) (conte
return ctx, false
}

if url.Path == "/results" {
return ctx, false
}

q := url.Query()
// TODO(go1.18): Replace with q.Has("v") once we've transitioned to at least go 1.17 as least supported version
if q.Has("v") {
Expand Down
5 changes: 5 additions & 0 deletions internal/resolvers/youtube/channel_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func TestChannelResolver(t *testing.T) {
input: utils.MustParseURL("https://youtube.com"),
expected: false,
},
{
label: "Correct domain, results path",
input: utils.MustParseURL("https://youtube.com/results?search_query=test"),
expected: false,
},
{
label: "Incorrect domain",
input: utils.MustParseURL("https://example.com/watch?v=foobar"),
Expand Down

0 comments on commit 9b8acaa

Please sign in to comment.