From f1782974522240cf4016b80a8accba223a8f7922 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sun, 28 Mar 2021 23:05:54 -0700 Subject: [PATCH] Generalize redirect route --- src/invidious/routes/misc.cr | 9 ++------- src/invidious/views/components/item.ecr | 2 +- src/invidious/views/search.ecr | 2 +- src/invidious/views/watch.ecr | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index c14e0e54..13fc65bb 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -38,12 +38,7 @@ class Invidious::Routes::Misc < Invidious::Routes::BaseRoute def cross_instance_redirect(env) instance_url = fetch_random_instance - if env.params.query["id"]? - id = env.params.query["id"] - env.redirect "https://#{instance_url}/watch?v=#{id}" - elsif env.params.query["q"]? - query, page = env.params.query["q"], env.params.query["page"] - env.redirect "https://#{instance_url}/search?q=#{query}&page=#{page}" - end + referer = get_referer(env) + env.redirect "https://#{instance_url}#{referer}" end end diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 0e379e8e..532de6ac 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -148,7 +148,7 @@ " href="/watch?v=<%= item.id %>&listen=1"> - " href="/redirect?id=<%= item.id %>&listen=1"> + " href="/redirect?referer=<%= env.get?("current_page") %>"> diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index fdb9205c..db0a8d56 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -5,7 +5,7 @@ <% if count == 0 %>

- <%= translate(locale, "Broken?") %> <%= translate(locale, "Switch Invidious Instance") %> + <%= translate(locale, "Broken?") %> "><%= translate(locale, "Switch Invidious Instance") %>

<% else %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 6bb59d20..91e03725 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -110,7 +110,7 @@ we're going to need to do it here in order to allow for translations. (<%= translate(locale, "Embed") %>)

- <%= translate(locale, "Switch Invidious Instance") %> + "><%= translate(locale, "Switch Invidious Instance") %>