Add URL rewrites and tracking-param cleanup to URLDispatcher
Rewrite www.reddit.com to old.reddit.com and x.com to
xcancel.com via string-based redir decoders. Replace the
shell-script URL cleaner with an inline sanitize-url function
that calls trurl to strip tracking params (utm_*, fbclid, etc.).

Assisted-by: Claude Opus 4.6 via pi
change uwpmstvvwwplqrskpuwomzvusluruuws
commit c5e2db1a8722bb4662bf1a682ad29d9419b4f02a
author Alpha Chen <alpha@kejadlen.dev>
date
parent rxpqtopu
diff --git a/.hammerspoon/init.fnl b/.hammerspoon/init.fnl
index 4f9e4b5b..2799c0e9 100644
--- a/.hammerspoon/init.fnl
+++ b/.hammerspoon/init.fnl
@@ -2,6 +2,7 @@
 ;; unwrap `hs` here to localize it to just one place
 (local {: eventtap
         : execute
+        :fnutils {: map}
         : fs
         : hotkey
         : loadSpoon
@@ -94,6 +95,13 @@
 (Install:andUse :SleepCorners {:config {:feedbackSize 25 :neverSleepCorner "*"}
                                :start true})
 
+(fn sanitize-url [url]
+  (let [tracking-params [:utm_* :uta_* :fbclid :gclid]
+        trurl-cmd (.. :/opt/homebrew/bin/trurl " "
+                      (table.concat (map tracking-params #(.. "--qtrim " $1))
+                                    " "))]
+    (chomp (execute (.. trurl-cmd " --url \"" url "\"")))))
+
 (let [handlers {:firefox-dev :org.mozilla.firefoxdeveloperedition
                 :firefox :org.mozilla.firefox
                 :glide :app.glide-browser.glide
@@ -112,8 +120,12 @@
                             "/?"))
       url-patterns [["^https://(.*%.?)zoom.us/j/%d+" handlers.zoom]
                     [safari-patterns handlers.safari]]
-      ; url-redir-decoders [[:clean-url #(execute (.. "/Users/alpha/.dotfiles/bin/,clean-url" $4))]]
-      ]
+      url-redir-decoders [[:reddit
+                           "://www%.reddit%.com"
+                           "://old.reddit.com"
+                           true]
+                          [:xcancel "://x%.com" "://xcancel.com" true]
+                          [:trurl-sanitize #(sanitize-url $4) nil true]]]
   (Install:andUse :URLDispatcher {:config {:url_patterns url-patterns
                                            :url_redir_decoders url-redir-decoders
                                            :default_handler little-ff.open