Set domain to be nil by default

This commit is contained in:
Omar Roth 2019-03-03 11:55:14 -06:00
parent 66605196ad
commit 17cf0772fb
3 changed files with 9 additions and 4 deletions

View file

@ -10,4 +10,4 @@ db:
dbname: invidious
full_refresh: false
https_only: false
domain: invidio.us
domain:

View file

@ -1056,7 +1056,7 @@ post "/login" do |env|
end
if config.domain
env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", domain: ".#{config.domain}", value: sid, expires: Time.now + 2.years,
env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", domain: "#{config.domain}", value: sid, expires: Time.now + 2.years,
secure: secure, http_only: true)
else
env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", value: sid, expires: Time.now + 2.years,
@ -1118,7 +1118,7 @@ post "/login" do |env|
end
if config.domain
env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", domain: ".#{config.domain}", value: sid, expires: Time.now + 2.years,
env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", domain: "#{config.domain}", value: sid, expires: Time.now + 2.years,
secure: secure, http_only: true)
else
env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", value: sid, expires: Time.now + 2.years,

View file

@ -200,7 +200,12 @@ def make_host_url(ssl, host)
scheme = "http://"
end
return "#{scheme}#{host}"
if host
host = host.lchop(".")
return "#{scheme}#{host}"
else
return ""
end
end
def get_referer(env, fallback = "/")