From 4332d3043f2fa7ef8a320695a82dc1ef086a1f68 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Sun, 7 Feb 2021 18:47:31 +0100 Subject: [PATCH] Fix redirected youtu.be/ID shortlinks parameters ordering Previouly, /[ID]?autoplay=1&test1&test2 would redirect to /watch?autoplay=1&test1=&test2=&v=[ID] which is kind of ugly, and not how YouTube redirects youtu.be shortlinks. This is now redirecting to /watch?v=[ID]&autoplay=1&test1=&test2 --- api/redirects.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/redirects.js b/api/redirects.js index 34aa433..5a02ab3 100644 --- a/api/redirects.js +++ b/api/redirects.js @@ -4,9 +4,7 @@ const {redirect} = require("pinski/plugins") module.exports = [ { route: `/(${constants.regex.video_id})`, priority: -1, methods: ["GET"], code: async ({fill, url}) => { - const target = new URLSearchParams(url.search) - target.set("v", fill[0]) - return redirect(`/watch?${target}`, 301) + return redirect(`/watch?v=${fill[0]}${url.search.replace(/^\?/, "&")}`, 301) } } ]