From 6d7ae6f6384212ad5a65edbd7383ac425f5b8bff Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 9 Mar 2018 14:13:26 -0600 Subject: [PATCH] Only add HTTP query if it exists --- src/invidious.cr | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 70c4a3f0..9936bd39 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -343,7 +343,10 @@ if Kemal.config.ssl && redirect spawn do server = HTTP::Server.new("0.0.0.0", 80) do |context| context.response.headers.add "Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload" - redirect_url = "https://#{context.request.host}#{context.request.path}?#{context.request.query}" + redirect_url = "https://#{context.request.host}#{context.request.path}" + if context.request.query + redirect_url += "?#{context.request.query}" + end context.response.headers.add "Location", redirect_url context.response.status_code = 301 end