summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-09-11 23:02:53 +0800
committereltrac <hi@eltr.ac>2026-09-11 23:02:53 +0800
commit15069bc1f24d8053567183523f98ff7edafa53c8 (patch)
treedb8639cf3d6a13a107332ed88ff4840b5d69ebee /src
parent65bc31943f28528cb46f2ee2ba7999b78474b936 (diff)
fix #22
1. nil guard `status` 2. upgrade `http-kit` to fix SNI issue 3. match Content-Type correctly
Diffstat (limited to 'src')
-rw-r--r--src/weepinbell/verifier.clj14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/weepinbell/verifier.clj b/src/weepinbell/verifier.clj
index 95ea686..613eadc 100644
--- a/src/weepinbell/verifier.clj
+++ b/src/weepinbell/verifier.clj
@@ -4,14 +4,18 @@
1) source contains target URL.
2) source respond with 2** status code.
3) source's Content-Type is either HTML or plain text."
- (:require [clojure.string :refer [includes?]]
+ (:require [clojure.string :refer [includes? trim lower-case split]]
[org.httpkit.client :as hk]
[taoensso.timbre :as timbre]))
(defn- verify-headers [headers]
- (#{"text/html" "text/plain"} (:content-type headers)))
-
-(verify-headers {:content-type "text/html"})
+ (when-let [content-type (:content-type headers)]
+ (-> content-type
+ (split #";")
+ first
+ trim
+ lower-case
+ (#{"text/html" "text/plain"}))))
(defn verify-mention
"Get source and follow redirects to check if target link is present."
@@ -22,7 +26,7 @@
(let [{:keys [status body headers]} @(hk/get source {:headers {"Range" "bytes=0-1048575"}})
target-headers (:headers @(hk/head target))]
;; Verify status code
- (if (and (>= status 200) (< status 300))
+ (if (and status (>= status 200) (< status 300))
;; Verify Content-Types
(if (and (verify-headers headers)
(verify-headers target-headers))