diff --git a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizer.kt b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizer.kt index 3e896ef8..68111673 100644 --- a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizer.kt +++ b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizer.kt @@ -37,5 +37,6 @@ class YoutubeSanitizer : name = context.getString(R.string.sanitizer_youtube_name), ) - override fun matchesDomain(input: String) = input.matchesDomainRegex("(m\\.)?youtube\\.com") + override fun matchesDomain(input: String) = + input.matchesDomainRegex("(?:m(?:usic)?\\.)?youtube\\.com") } diff --git a/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizerTest.kt b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizerTest.kt index 82fa6409..c4967c0c 100644 --- a/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizerTest.kt +++ b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/youtube/YoutubeSanitizerTest.kt @@ -46,6 +46,13 @@ class YoutubeSanitizerTest : ) shouldBe "https://youtube.com/playlist?list=PLkqz3S84Tw-QYEdfTLBzxJ1FAprtqeEpJ" } + + "remove all parameters except \"v\" from YouTube Music URLs" { + sanitizer( + "https://music.youtube.com/watch?v=KGFkMD2zotU&si=JrZ7QzX4VeMrfzp8", + ) shouldBe + "https://music.youtube.com/watch?v=KGFkMD2zotU" + } } "matchesDomain" should { @@ -57,6 +64,10 @@ class YoutubeSanitizerTest : "match m.youtube.com domain" { sanitizer.matchesDomain("https://m.youtube.com/") shouldBe true } + + "match music.youtube.com domain" { + sanitizer.matchesDomain("https://music.youtube.com/") shouldBe true + } } }, )