Skip to content

Commit

Permalink
Reduce logging in unshortenUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed May 5, 2023
1 parent aa95461 commit be7b0c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ http.unshortenUrl = function(url)
local purl = url
local nurl = url
local count = 0
local logger = hs.logger.new("unshorten", "info")

while nurl ~= nil do
local uri = hs.http.urlParts(nurl)
Expand All @@ -76,8 +77,6 @@ http.unshortenUrl = function(url)
local host = uri.host:lower()
local isShortener = false
for _, domain in ipairs(http.shortenerHosts) do
logger = hs.logger.new("unshorten", "info")
logger.i(host, domain, "." .. domain)
if host == domain or utils.string.endsWith(host, "." .. domain) then
isShortener = true
break
Expand All @@ -86,6 +85,7 @@ http.unshortenUrl = function(url)
if not isShortener then
return nurl, nil
end
logger.i(host)
if count >= 3 then
return nurl, "too many redirects"
end
Expand Down

0 comments on commit be7b0c4

Please sign in to comment.