mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Fix video ID redirect
This commit is contained in:
parent
01e5bec246
commit
2e69774b1f
1 changed files with 15 additions and 11 deletions
|
@ -378,7 +378,7 @@ get "/watch" do |env|
|
||||||
scheme = "https://"
|
scheme = "https://"
|
||||||
else
|
else
|
||||||
scheme = "http://"
|
scheme = "http://"
|
||||||
end
|
end
|
||||||
host = env.request.headers["Host"]
|
host = env.request.headers["Host"]
|
||||||
url = "#{scheme}#{host}"
|
url = "#{scheme}#{host}"
|
||||||
|
|
||||||
|
@ -2615,18 +2615,22 @@ end
|
||||||
get "/:id" do |env|
|
get "/:id" do |env|
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
|
|
||||||
params = [] of String
|
if md = id.match(/[a-zA-Z0-9_-]{11}/)
|
||||||
env.params.query.each do |k, v|
|
params = [] of String
|
||||||
params << "#{k}=#{v}"
|
env.params.query.each do |k, v|
|
||||||
end
|
params << "#{k}=#{v}"
|
||||||
params = params.join("&")
|
end
|
||||||
|
params = params.join("&")
|
||||||
|
|
||||||
url = "/watch?v=#{id}"
|
url = "/watch?v=#{id}"
|
||||||
if params
|
if params
|
||||||
url += "&#{params}"
|
url += "&#{params}"
|
||||||
end
|
end
|
||||||
|
|
||||||
env.redirect url
|
env.redirect url
|
||||||
|
else
|
||||||
|
env.response.status_code = 404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
error 404 do |env|
|
error 404 do |env|
|
||||||
|
|
Loading…
Reference in a new issue