Skip to content

Commit

Permalink
fix: YT sanitizer for playlist URLs (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs authored Jan 4, 2024
1 parent 8d57785 commit 82f32b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Léon - The URL Cleaner
* Copyright (C) 2023 Sven Jacobs
* Copyright (C) 2024 Sven Jacobs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -28,7 +28,7 @@ import com.svenjacobs.app.leon.core.domain.sanitizer.SanitizerId

class YoutubeSanitizer :
RegexSanitizer(
RegexFactory.exceptParameter("(v|search_query)"),
RegexFactory.exceptParameter("(v|search_query|list)"),
) {

override val id = SanitizerId("youtube")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Léon - The URL Cleaner
* Copyright (C) 2023 Sven Jacobs
* Copyright (C) 2024 Sven Jacobs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -28,16 +28,24 @@ class YoutubeSanitizerTest :

"invoke" should {

"remove all parameters except v= from video URLs" {
"remove all parameters except \"v\" from video URLs" {
sanitizer(
"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 search_query= from search URLs" {
"remove all parameters except \"search_query\" from search URLs" {
sanitizer("https://m.youtube.com/results?sp=mAEA&search_query=funny+dog+video") shouldBe
"https://m.youtube.com/results&search_query=funny+dog+video"
}

"remove all parameters except \"list\" from playlist URLs" {
sanitizer(
"https://youtube.com/playlist?list=PLkqz3S84Tw-QYEdfTLBzxJ1FAprtqeE" +
"pJ&si=2tDDmSKejG2GTtj5",
) shouldBe
"https://youtube.com/playlist?list=PLkqz3S84Tw-QYEdfTLBzxJ1FAprtqeEpJ"
}
}

"matchesDomain" should {
Expand Down

0 comments on commit 82f32b6

Please sign in to comment.