Skip to content

Commit

Permalink
Fix #135: Correctly resolve children for custom Paths (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohalt authored Jan 9, 2025
1 parent ab826ff commit 603b290
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/babashka/fs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
(as-path f))
(^Path [parent child]
(if parent
(.resolve (as-path parent) (as-path child))
(if (string? child)
(.resolve ^Path (as-path parent) ^String child)
(.resolve ^Path (as-path parent) (as-path child)))
(as-path child)))
(^Path [parent child & more]
(reduce path (path parent child) more)))
Expand Down
5 changes: 5 additions & 0 deletions test/babashka/fs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -835,3 +835,8 @@
file-in-dir (fs/create-temp-file {:dir dir})]
(is (= (str (fs/owner dir)) (str (fs/owner file-in-dir)))))))

(deftest issue-135-test
(let [uri (java.net.URI/create (str "jar:file:" (fs/unixify (fs/cwd)) "/test-resources/bencode-1.1.0.jar"))
fs (java.nio.file.FileSystems/newFileSystem uri {})
path-in-zip (.getPath ^java.nio.file.FileSystem fs "/bencode" (into-array String []))]
(is (fs/path path-in-zip "core.clj"))))

0 comments on commit 603b290

Please sign in to comment.