mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Fix toggle_theme when visiting preferences with JS disabled
This commit is contained in:
parent
d6ec441c8e
commit
352e409a6e
2 changed files with 11 additions and 9 deletions
|
@ -1487,7 +1487,7 @@ end
|
||||||
|
|
||||||
get "/toggle_theme" do |env|
|
get "/toggle_theme" do |env|
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
referer = get_referer(env)
|
referer = get_referer(env, unroll: false)
|
||||||
|
|
||||||
redirect = env.params.query["redirect"]?
|
redirect = env.params.query["redirect"]?
|
||||||
redirect ||= "true"
|
redirect ||= "true"
|
||||||
|
|
|
@ -243,7 +243,7 @@ def make_host_url(config, kemal_config)
|
||||||
return "#{scheme}#{host}#{port}"
|
return "#{scheme}#{host}#{port}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_referer(env, fallback = "/")
|
def get_referer(env, fallback = "/", unroll = true)
|
||||||
referer = env.params.query["referer"]?
|
referer = env.params.query["referer"]?
|
||||||
referer ||= env.request.headers["referer"]?
|
referer ||= env.request.headers["referer"]?
|
||||||
referer ||= fallback
|
referer ||= fallback
|
||||||
|
@ -251,6 +251,7 @@ def get_referer(env, fallback = "/")
|
||||||
referer = URI.parse(referer)
|
referer = URI.parse(referer)
|
||||||
|
|
||||||
# "Unroll" nested referrers
|
# "Unroll" nested referrers
|
||||||
|
if unroll
|
||||||
loop do
|
loop do
|
||||||
if referer.query
|
if referer.query
|
||||||
params = HTTP::Params.parse(referer.query.not_nil!)
|
params = HTTP::Params.parse(referer.query.not_nil!)
|
||||||
|
@ -263,6 +264,7 @@ def get_referer(env, fallback = "/")
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
referer = referer.full_path
|
referer = referer.full_path
|
||||||
referer = "/" + referer.lstrip("\/\\")
|
referer = "/" + referer.lstrip("\/\\")
|
||||||
|
|
Loading…
Reference in a new issue