1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

test(rewrite): fix flaky test case by sorting query string keys

This commit is contained in:
Frédéric Guillot 2025-08-05 17:26:31 -07:00
parent e8e3a600b4
commit 0f3c04a98a
2 changed files with 10 additions and 11 deletions

View file

@ -331,20 +331,19 @@ func addInvidiousVideo(entryURL, entryContent string) string {
return entryContent
}
v := u.Query().Get("v")
if v == "" {
qs := u.Query()
videoID := qs.Get("v")
if videoID == "" {
return entryContent
}
qs.Del("v")
src := "https://" + u.Hostname() + `/embed/` + v
for key, val := range u.Query() {
if key == "v" || len(val) != 1 {
continue
}
src += "&" + key + "=" + val[0]
embedVideoURL := "https://" + u.Hostname() + `/embed/` + videoID
if len(qs) > 0 {
embedVideoURL += "?" + qs.Encode()
}
return addVideoPlayerIframe(src, entryContent)
return addVideoPlayerIframe(embedVideoURL, entryContent)
}
func addPDFLink(entryURL, entryContent string) string {

View file

@ -284,13 +284,13 @@ func TestAddInvidiousVideo(t *testing.T) {
// Test with query parameters
"https://invidious.io/watch?v=dQw4w9WgXcQ&t=30s": {
"Video with timestamp",
`<iframe width="650" height="350" frameborder="0" src="https://invidious.io/embed/dQw4w9WgXcQ&t=30s" allowfullscreen></iframe><br>Video with timestamp`,
`<iframe width="650" height="350" frameborder="0" src="https://invidious.io/embed/dQw4w9WgXcQ?t=30s" allowfullscreen></iframe><br>Video with timestamp`,
},
// Test with more complex query parameters
"https://invidious.io/watch?v=dQw4w9WgXcQ&t=30s&autoplay=1": {
"Video with multiple parameters",
`<iframe width="650" height="350" frameborder="0" src="https://invidious.io/embed/dQw4w9WgXcQ&t=30s&autoplay=1" allowfullscreen></iframe><br>Video with multiple parameters`,
`<iframe width="650" height="350" frameborder="0" src="https://invidious.io/embed/dQw4w9WgXcQ?autoplay=1&t=30s" allowfullscreen></iframe><br>Video with multiple parameters`,
},
// Test with non-matching URLs (should return content unchanged)