Skip to content

Commit

Permalink
Fix search failing when query contains certain characters (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Apr 22, 2024
1 parent 4852ebb commit 391bb3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions YoutubeExplode.Tests/SearchSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ public async Task I_can_get_results_from_a_search_query()
results.Should().HaveCountGreaterOrEqualTo(50);
}

[Fact]
public async Task I_can_get_results_from_a_search_query_that_contains_special_characters()
{
// Arrange
var youtube = new YoutubeClient();

// Act
var results = await youtube.Search.GetResultsAsync("\"dune 2\" ending");

// Assert
results.Should().HaveCountGreaterOrEqualTo(50);
}

[Fact]
public async Task I_can_get_video_results_from_a_search_query()
{
Expand Down
5 changes: 3 additions & 2 deletions YoutubeExplode/Search/SearchController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net.Http;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using YoutubeExplode.Bridge;
Expand All @@ -23,7 +24,7 @@ public async ValueTask<SearchResponse> GetSearchResponseAsync(
// lang=json
$$"""
{
"query": "{{searchQuery}}",
"query": "{{WebUtility.UrlEncode(searchQuery)}}",
"params": "{{searchFilter switch
{
SearchFilter.Video => "EgIQAQ%3D%3D",
Expand Down

0 comments on commit 391bb3f

Please sign in to comment.