mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-21 10:49:02 -05:00
fix #3933
swichted the order of checking for channel links and youtu.be/videoid short links to prevent redirecting to / because of empty response body for video
This commit is contained in:
parent
bea747c3c0
commit
3625ed3620
@ -15,19 +15,6 @@ module Invidious::Routes::ErrorRoutes
|
|||||||
response = YT_POOL.client &.get(URI.parse(response.headers["Location"]).request_target)
|
response = YT_POOL.client &.get(URI.parse(response.headers["Location"]).request_target)
|
||||||
end
|
end
|
||||||
|
|
||||||
#if response.body.empty?
|
|
||||||
# env.response.headers["Location"] = "/"
|
|
||||||
# haltf env, status_code: 302
|
|
||||||
#end
|
|
||||||
|
|
||||||
#html = XML.parse_html(response.body)
|
|
||||||
#ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1]
|
|
||||||
|
|
||||||
#if ucid
|
|
||||||
# env.response.headers["Location"] = "/channel/#{ucid}"
|
|
||||||
# haltf env, status_code: 302
|
|
||||||
#end
|
|
||||||
|
|
||||||
params = [] of String
|
params = [] of String
|
||||||
env.params.query.each do |k, v|
|
env.params.query.each do |k, v|
|
||||||
params << "#{k}=#{v}"
|
params << "#{k}=#{v}"
|
||||||
@ -44,6 +31,19 @@ module Invidious::Routes::ErrorRoutes
|
|||||||
env.response.headers["Location"] = url
|
env.response.headers["Location"] = url
|
||||||
haltf env, status_code: 302
|
haltf env, status_code: 302
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if response.body.empty?
|
||||||
|
env.response.headers["Location"] = "/"
|
||||||
|
haltf env, status_code: 302
|
||||||
|
end
|
||||||
|
|
||||||
|
html = XML.parse_html(response.body)
|
||||||
|
ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1]
|
||||||
|
|
||||||
|
if ucid
|
||||||
|
env.response.headers["Location"] = "/channel/#{ucid}"
|
||||||
|
haltf env, status_code: 302
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
env.response.headers["Location"] = "/"
|
env.response.headers["Location"] = "/"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user