diff --git a/src/Lavalink4NET.Rest/LavalinkApiClient.cs b/src/Lavalink4NET.Rest/LavalinkApiClient.cs index f008b697..19353a59 100644 --- a/src/Lavalink4NET.Rest/LavalinkApiClient.cs +++ b/src/Lavalink4NET.Rest/LavalinkApiClient.cs @@ -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 diff --git a/tests/Lavalink4NET.Rest.Tests/LavalinkApiClientTests.cs b/tests/Lavalink4NET.Rest.Tests/LavalinkApiClientTests.cs index 46cfa0e3..4808aa44 100644 --- a/tests/Lavalink4NET.Rest.Tests/LavalinkApiClientTests.cs +++ b/tests/Lavalink4NET.Rest.Tests/LavalinkApiClientTests.cs @@ -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