fix(backend switcher): pass referer in URL
Some checks are pending
Build and release container directly from master / release (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.12.1, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.13.2, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.14.0, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.15.0, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (nightly, false) (push) Waiting to run
Invidious CI / build-docker (push) Waiting to run
Invidious CI / build-docker-arm64 (push) Waiting to run
Invidious CI / lint (push) Waiting to run

Closes https://git.nadeko.net/Fijxu/invidious/issues/109

This will allow browsers that by default set the referer to the same
page to tracking via the referer header. IceCat browser does this.
This commit is contained in:
Fijxu 2025-05-08 20:22:29 -04:00
parent 4e2f59ba37
commit caa2273bf2
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4
2 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,7 @@
module Invidious::Routes::BackendSwitcher
def self.switch(env)
referer = get_referer(env)
referer = get_referer(env, unroll: false)
backend_id = env.params.query["backend_id"]?.try &.to_i
if backend_id.nil?

View File

@ -133,8 +133,9 @@
<% end %>
<% end %>
<% else %>
<% current_page = env.get("current_page") %>
<% CONFIG.invidious_companion.each_with_index do | companion, index | %>
<a href="/switchbackend?backend_id=<%= index.to_s %>" style="<%= current_backend == index ? "text-decoration-line: underline;" : "" %> display: inline-block;">
<a href="/switchbackend?backend_id=<%= index.to_s %>&referer=<%= current_page %>" style="<%= current_backend == index ? "text-decoration-line: underline;" : "" %> display: inline-block;">
Backend<%= HTML.escape((index + 1).to_s) %> <%= HTML.escape(companion.note) %>
<span style="color:
<% if status[index] == 0 %> #fd4848; <% end %>