diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-08-05 14:37:32 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-08-05 14:37:32 -0500 |
| commit | a29458e32f4a32aab9ab8c9d0b5e6fc7c4eb6d1e (patch) | |
| tree | e923832965e6d0ee7060714a01f5b56602eb1fcb | |
| parent | d51b23bc167bce212b7b93303031023694fd877c (diff) | |
| download | invidious-a29458e32f4a32aab9ab8c9d0b5e6fc7c4eb6d1e.tar.gz invidious-a29458e32f4a32aab9ab8c9d0b5e6fc7c4eb6d1e.tar.bz2 invidious-a29458e32f4a32aab9ab8c9d0b5e6fc7c4eb6d1e.zip | |
Allow 'host' header to be optional
| -rw-r--r-- | src/invidious.cr | 10 | ||||
| -rw-r--r-- | src/invidious/helpers/utils.cr | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 6c1cc5cd..97d01d0a 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -216,7 +216,7 @@ get "/watch" do |env| video.description = add_alt_links(video.description) description = video.short_description - host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]) + host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?) host_params = env.request.query_params host_params.delete_all("v") @@ -306,7 +306,7 @@ get "/embed/:id" do |env| video.description = add_alt_links(video.description) description = video.short_description - host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]) + host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?) host_params = env.request.query_params host_params.delete_all("v") @@ -847,7 +847,7 @@ get "/subscription_manager" do |env| subscriptions.sort_by! { |channel| channel.author.downcase } if action_takeout - host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]) + host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?) if format == "json" env.response.content_type = "application/json" @@ -1259,7 +1259,7 @@ get "/feed/channel/:ucid" do |env| content_html = json["content_html"].as_s document = XML.parse_html(content_html) - host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]) + host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?) path = env.request.path feed = XML.build(indent: " ", encoding: "UTF-8") do |xml| @@ -1416,7 +1416,7 @@ get "/feed/private" do |env| videos = videos[0..max_results] end - host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]) + host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?) path = env.request.path query = env.request.query.not_nil! diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index d457ea3b..4adc8ec2 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -135,5 +135,7 @@ def make_host_url(ssl, host) scheme = "http://" end + host ||= "invidio.us" + return "#{scheme}#{host}" end |
