Skip to content

Commit f57899d

Browse files
committed
print the links for clues about the missing link
1 parent cb7d077 commit f57899d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

script/analyze_links.clj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,23 @@
88
[clojure.string :as str]
99
[clojure.walk :as walk]))
1010

11-
12-
13-
14-
(defn- url-ok? [url]
11+
(defn- url-ok?
1512
"Returns true if the given URL responds with a 2xx HTTP status.
1613
Uses `babashka.curl` with `:throw false` to avoid exceptions on failure.
1714
Returns false on error or non-2xx status."
15+
[url]
1816
(try
1917
(let [{:keys [status]} (curl/get url {:throw false})]
2018
(<= 200 status 299))
2119
(catch Exception _ false)))
2220

23-
(defn- broken-links* [missing-paths]
21+
(defn- broken-links*
2422
"Takes a collection of relative paths and checks their availability
2523
by making HTTP GET requests to https://metabase.com/<path>. Uses a fixed-size
2624
thread pool to parallelize the checks. Returns a map with:
2725
- :broken-count — the number of unreachable URLs
2826
- :broken — a vector of paths that failed the check"
27+
[missing-paths]
2928
(let [pool (java.util.concurrent.Executors/newFixedThreadPool 100)
3029
tasks (map (fn [p]
3130
(fn [] (if (url-ok? (str "https://metabase.com/" p)) nil p)))
@@ -127,6 +126,10 @@
127126
_ (println (count external-or-missing-links) "reported links without redirects.")
128127
_ (println "Checking if the missing links are live on https://metabase.com ...")
129128
out (check-broken-links external-or-missing-links)]
129+
(prn ["htmlproofer links:" (set htmlproofer-links)])
130+
(prn ["redirects:" (set redirects)])
131+
(prn ["external-or-missing-links:" (set external-or-missing-links)])
132+
130133
(if (zero? (:broken-count out))
131134
(do
132135
(println "Done. OK.")

0 commit comments

Comments
 (0)