Skip to content

Commit

Permalink
fix: YT sanitizer should clean YT music domains (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs authored Mar 16, 2024
1 parent 9466443 commit 891a4b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
},
)

0 comments on commit 891a4b0

Please sign in to comment.