Skip to content

Commit

Permalink
fix: YouTube sanitizer should also clean youtu.be domain (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs authored Nov 24, 2024
1 parent c61d66d commit 1336218
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ class YoutubeSanitizer :
)

override fun matchesDomain(input: String) =
input.matchesDomainRegex("(?:m(?:usic)?\\.)?youtube\\.com")
input.matchesDomainRegex("(?:(?:(?:m(?:usic)?\\.)?youtube\\.com)|youtu\\.be)")
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class YoutubeSanitizerTest :
"https://m.youtube.com/watch?v=CvFH_6DNRCY&pp=ygUHZGVidXNzeQ%3D%3D",
) shouldBe "https://m.youtube.com/watch?v=CvFH_6DNRCY"
}

"remove all parameters except \"t\" from video URLs" {
sanitizer(
"https://m.youtube.com/watch?v=CvFH_6DNRCY&t=125",
Expand All @@ -59,6 +59,12 @@ class YoutubeSanitizerTest :
) shouldBe
"https://music.youtube.com/watch?v=KGFkMD2zotU"
}

"remove parameters from youtu.be domain" {
sanitizer(
"https://youtu.be/RvRhUHTV_8k?si=OXYBmGTMXib1jlA2?si=UA0UVnrmPbK612Lu",
) shouldBe "https://youtu.be/RvRhUHTV_8k"
}
}

"matchesDomain" should {
Expand All @@ -74,6 +80,10 @@ class YoutubeSanitizerTest :
"match music.youtube.com domain" {
sanitizer.matchesDomain("https://music.youtube.com/") shouldBe true
}

"match youtu.be domain" {
sanitizer.matchesDomain("https://youtu.be/") shouldBe true
}
}
},
)

0 comments on commit 1336218

Please sign in to comment.