Skip to content

Commit

Permalink
fix: Lower strict search strictness
Browse files Browse the repository at this point in the history
  • Loading branch information
angelobreuer committed Dec 1, 2023
1 parent bc52f0d commit ec4a358
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Lavalink4NET.Rest/LavalinkApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ internal static string BuildIdentifier(string identifier, TrackLoadOptions loadO
: $"{loadOptions.SearchMode.Prefix}:{identifier}";
}

var separatorIndex = identifier.AsSpan().IndexOf(':');
var separatorIndex = identifier.AsSpan().IndexOfAny(':', ' ', '\t');

if (separatorIndex is -1)
if (separatorIndex is -1 || identifier[separatorIndex] is not ':')
{
return loadOptions.SearchMode.Prefix is null
? identifier
Expand Down
2 changes: 2 additions & 0 deletions tests/Lavalink4NET.Rest.Tests/LavalinkApiClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class LavalinkApiClientTests
[InlineData("ytsearch:abc", "ytsearch:abc", null, false)]
[InlineData("scsearch:abc", "scsearch:abc", null, false)]
[InlineData("othersearch:abc", "othersearch:abc", null, false)]
[InlineData("other search:abc", "othersearch:other search:abc", "othersearch", true)]
[InlineData("ABC https://www.youtube.com/watch?v=ABC&t=248", "ytsearch:ABC https://www.youtube.com/watch?v=ABC&t=248", "ytsearch", true)]
public void TestBuildIdentifier(string identifier, string expected, string searchMode, bool strict)
{
// Arrange
Expand Down

0 comments on commit ec4a358

Please sign in to comment.