mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-06-27 17:38:25 +00:00
fix missing scheme error
This commit is contained in:
parent
6e9858080d
commit
75e27c3aa7
@ -203,6 +203,9 @@ class Config
|
|||||||
# Invidious companion API key
|
# Invidious companion API key
|
||||||
property invidious_companion_key : String = ""
|
property invidious_companion_key : String = ""
|
||||||
|
|
||||||
|
# Invidious companion prefix for numbered domains
|
||||||
|
property invidious_companion_prefix : String = ""
|
||||||
|
|
||||||
# Saved cookies in "name1=value1; name2=value2..." format
|
# Saved cookies in "name1=value1; name2=value2..." format
|
||||||
@[YAML::Field(converter: Preferences::StringToCookies)]
|
@[YAML::Field(converter: Preferences::StringToCookies)]
|
||||||
property cookies : HTTP::Cookies = HTTP::Cookies.new
|
property cookies : HTTP::Cookies = HTTP::Cookies.new
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
module Invidious::Routes::BeforeAll
|
module Invidious::Routes::BeforeAll
|
||||||
|
private COMPANION_PREFIXES = [] of String
|
||||||
|
|
||||||
|
CONFIG.invidious_companion.each_with_index do |_, i|
|
||||||
|
prefix = CONFIG.invidious_companion_prefix + "#{i + 1}"
|
||||||
|
COMPANION_PREFIXES << prefix
|
||||||
|
end
|
||||||
|
|
||||||
def self.handle(env)
|
def self.handle(env)
|
||||||
preferences = Preferences.from_json("{}")
|
preferences = Preferences.from_json("{}")
|
||||||
host = env.request.headers["Host"]
|
host = env.request.headers["Host"]
|
||||||
@ -25,13 +32,12 @@ module Invidious::Routes::BeforeAll
|
|||||||
extra_connect_csp = ""
|
extra_connect_csp = ""
|
||||||
|
|
||||||
if CONFIG.invidious_companion.present?
|
if CONFIG.invidious_companion.present?
|
||||||
current_companion_d = host.split(".")[0].scan(/(\d+)$/).last?.try &.[0].to_i
|
current_companion_d = host.split(":")[0].split(".")[0]
|
||||||
|
|
||||||
if current_companion_d
|
if index = COMPANION_PREFIXES.index(current_companion_d)
|
||||||
current_companion_d = current_companion_d - 1
|
|
||||||
env.set "using_domain", true
|
env.set "using_domain", true
|
||||||
env.set "current_companion", current_companion_d
|
env.set "current_companion", index
|
||||||
env.set "companion_public_url", CONFIG.invidious_companion[current_companion_d].public_url.to_s
|
env.set "companion_public_url", CONFIG.invidious_companion[index].public_url.to_s
|
||||||
else
|
else
|
||||||
if !env.request.cookies[CONFIG.server_id_cookie_name]?
|
if !env.request.cookies[CONFIG.server_id_cookie_name]?
|
||||||
env.response.cookies[CONFIG.server_id_cookie_name] = Invidious::User::Cookies.server_id(host)
|
env.response.cookies[CONFIG.server_id_cookie_name] = Invidious::User::Cookies.server_id(host)
|
||||||
|
Loading…
Reference in New Issue
Block a user