summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorepicsam123 <92618898+epicsam123@users.noreply.github.com>2025-01-25 03:24:38 -0500
committerGitHub <noreply@github.com>2025-01-25 03:24:38 -0500
commit0fd480bae2f22848528f0f526bbae410801d486d (patch)
tree88233dad8feac295061eba5a57c2c7aa900e4600
parentafb0aad7d36bf907b46df87432c65a9b45eb678d (diff)
downloadinvidious-0fd480bae2f22848528f0f526bbae410801d486d.tar.gz
invidious-0fd480bae2f22848528f0f526bbae410801d486d.tar.bz2
invidious-0fd480bae2f22848528f0f526bbae410801d486d.zip
lint edits, refactor
-rw-r--r--src/invidious/routes/misc.cr25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr
index 96d6e61f..09248145 100644
--- a/src/invidious/routes/misc.cr
+++ b/src/invidious/routes/misc.cr
@@ -40,24 +40,19 @@ module Invidious::Routes::Misc
def self.cross_instance_redirect(env)
referer = get_referer(env)
- redirect_url = "redirect.invidious.io"
instance_list = Invidious::Jobs::InstanceListRefreshJob::INSTANCES["INSTANCES"]
- if instance_list.empty?
- instance_url = redirect_url
- else
- # Filter out the current instance
- other_available_instances = instance_list.reject! { |region, domain| domain == CONFIG.domain }
+ # Filter out the current instance
+ other_available_instances = instance_list.reject! { |_, domain| domain == CONFIG.domain }
- # If there are any other instances, select a random one
- if other_available_instances.any?
- # Sample returns an array
- # Instances are packaged as {region, domain} in the instance list
- instance_url = other_available_instances.sample(1)[0][1]
- else
- # If the current instance is the only one, use the redirect URL as fallback
- instance_url = redirect_url
- end
+ if other_available_instances.empty?
+ # If the current instance is the only one, use the redirect URL as fallback
+ instance_url = "redirect.invidious.io"
+ else
+ # Select other random instance
+ # Sample returns an array
+ # Instances are packaged as {region, domain} in the instance list
+ instance_url = other_available_instances.sample(1)[0][1]
end
env.redirect "https://#{instance_url}#{referer}"