From 326bd4fd0d1f1ef619ce9f4a37f7827dbb9031a7 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Fri, 3 Feb 2023 12:10:48 +0900 Subject: [PATCH] http.unshortenUrl recognizes subdomains of http.shortenerHosts --- http.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/http.lua b/http.lua index 30ea024..a89f703 100644 --- a/http.lua +++ b/http.lua @@ -74,7 +74,16 @@ http.unshortenUrl = function(url) return purl, "host is missing" end local host = uri.host:lower() - if fnutils.indexOf(http.shortenerHosts, host) == nil then + 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 + end + end + if not isShortener then return nurl, nil end if count >= 3 then