From 17cf0772fb9ab483391942a33fec6e71aa25128d Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 3 Mar 2019 11:55:14 -0600 Subject: Set domain to be nil by default --- src/invidious.cr | 4 ++-- src/invidious/helpers/utils.cr | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/invidious.cr b/src/invidious.cr index d9b88a0c..88f258c6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -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, diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index f5838622..5ccc1009 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -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 = "/") -- cgit v1.2.3