From 116a260de1b8d29320cc76f15314447cce1826b4 Mon Sep 17 00:00:00 2001 From: Sebastian Probst Eide Date: Thu, 11 Jul 2024 12:08:23 +0200 Subject: [PATCH] Include port number if present Port numbers were ignored when creating the host url to check. This has caused some issues in my usage of Gollum. This change explicitly includes the port number provided as long as it's not the standard port for the protocol used. I.e. - http://domain:40 will produce the equivalent host - http://domain:80 will produce http://domain --- lib/gollum.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/gollum.ex b/lib/gollum.ex index 262dab2..cb905a8 100644 --- a/lib/gollum.ex +++ b/lib/gollum.ex @@ -47,7 +47,12 @@ defmodule Gollum do name = opts[:name] || Gollum.Cache uri = URI.parse(url) - host = "#{uri.scheme}://#{uri.host}" + port = case {uri.port, uri.scheme} do + {80, "http"} -> "" + {443, "https"} -> "" + {port, _} -> ":#{port}" + end + host = "#{uri.scheme}://#{uri.host}#{port}" path = uri.path || "/" case Cache.fetch(host, name: name) do