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
This commit is contained in:
Lomanic 2021-02-07 18:47:31 +01:00 committed by Cadence Ember
parent 6f8eb43e24
commit 4332d3043f
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17
1 changed files with 1 additions and 3 deletions

View File

@ -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)
}
}
]