(defn ^String relative-name
"Given a file return a path relative to the working directory. Given a
URL return the JAR relative path of the resource."
[x]
{:pre [(or (file? x) (url? x))]}
(letfn [(strip-user-dir [s]
(let [user-dir (System/getProperty "user.dir")
s (normalize-path s)
user-path (cond-> user-dir
(not (.endsWith user-dir File/separator))
(str File/separator))]
(string/replace s user-path "")))]
(if (file? x)
(strip-user-dir (.getAbsolutePath x))
(let [f (URLDecoder/decode (.getFile x))]
(if (string/includes? f ".jar!/")
(last (string/split f #"\.jar!/"))
(strip-user-dir f))))))