diff --git a/internal/reader/rewrite/content_rewrite_functions.go b/internal/reader/rewrite/content_rewrite_functions.go index 3a69223a..2f179c6d 100644 --- a/internal/reader/rewrite/content_rewrite_functions.go +++ b/internal/reader/rewrite/content_rewrite_functions.go @@ -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 { diff --git a/internal/reader/rewrite/content_rewrite_test.go b/internal/reader/rewrite/content_rewrite_test.go index 5627097d..40d624c8 100644 --- a/internal/reader/rewrite/content_rewrite_test.go +++ b/internal/reader/rewrite/content_rewrite_test.go @@ -284,13 +284,13 @@ func TestAddInvidiousVideo(t *testing.T) { // Test with query parameters "https://invidious.io/watch?v=dQw4w9WgXcQ&t=30s": { "Video with timestamp", - `
Video with timestamp`, + `
Video with timestamp`, }, // Test with more complex query parameters "https://invidious.io/watch?v=dQw4w9WgXcQ&t=30s&autoplay=1": { "Video with multiple parameters", - `
Video with multiple parameters`, + `
Video with multiple parameters`, }, // Test with non-matching URLs (should return content unchanged)