Skip to content

Commit 5b3d9db

Browse files
committed
Fix whitespace handle in uris.
Fixes #270
1 parent 5319b66 commit 5b3d9db

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix whitespace handle in uris. #270
6+
57
## 0.92.1
68

79
- Add `x-llm-application-name: eca` to prompt requests, useful to track and get metrics when using LLM gateways.

docs/examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ If you think your config is relevant to be shared for other people, [open a pull
133133
"customTools": {
134134
"clj-nrepl-eval": {
135135
"description": "${file:tools/clj-nrepl-eval.md}",
136-
"command": "clj-nrepl-eval -p $(cat .nrepl-port) $'{{code}}'",
136+
"command": "read -r -d '' CLJ_PAYLOAD << 'Mjz9q5s8' || true\n{{code}}\nMjz9q5s8\nclj-nrepl-eval -p $(cat .nrepl-port) \"$CLJ_PAYLOAD\"",
137137
"schema": {
138138
"properties": {
139139
"code": {

src/eca/shared.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
(System/lineSeparator))
2929

3030
(defn uri->filename [uri]
31-
(let [uri (-> (URI. uri)
32-
(.toASCIIString)
33-
(URI.))]
34-
(-> uri Paths/get .toString
31+
(let [^URI uri (-> uri
32+
(string/replace " " "%20")
33+
(URI.))]
34+
(-> (Paths/get uri) .toString
3535
;; WINDOWS drive letters
3636
(string/replace #"^[a-z]:\\" string/upper-case))))
3737

test/eca/shared_test.clj

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
(is (= (when h/windows? "C:\\Users\\FirstName LastName\\c.clj")
1616
(when h/windows? (shared/uri->filename "file:/c:/Users/FirstName%20LastName/c.clj"))))
1717
(is (= (when h/windows? "C:\\c.clj")
18-
(when h/windows? (shared/uri->filename "file:///c:/c.clj"))))))
18+
(when h/windows? (shared/uri->filename "file:///c:/c.clj")))))
19+
(testing "Spaces"
20+
(is (= (h/file-path "/Users/foo/Library/Some Document/comappleCloudDocs")
21+
(shared/uri->filename (h/file-uri "file:///Users/foo/Library/Some Document/comappleCloudDocs"))))))
1922

2023
(deftest assoc-some-test
2124
(testing "single association"
@@ -122,18 +125,18 @@
122125
(is (= "**" (shared/obfuscate "ab")))
123126
(is (= "****" (shared/obfuscate "abcd"))))
124127

125-
(testing "default preserve-num=3 with various lengths"
128+
(testing "default preserve-num=3 with various lengths"
126129
;; length 5: middle forced to at least 5 stars, preserve shrinks to floor(len/2)
127-
(is (= "ab*****de" (shared/obfuscate "abcde")))
130+
(is (= "ab*****de" (shared/obfuscate "abcde")))
128131
;; length 6: prefix 3, 5 stars, suffix 3 => 11 chars
129-
(is (= "abc*****def" (shared/obfuscate "abcdef")))
132+
(is (= "abc*****def" (shared/obfuscate "abcdef")))
130133
;; length 7: prefix 3, 5 stars, suffix 3 => 11 chars
131-
(is (= "abc*****efg" (shared/obfuscate "abcdefg")))
134+
(is (= "abc*****efg" (shared/obfuscate "abcdefg")))
132135
;; length 10: prefix 3, 5 stars, suffix 3 => 11 chars
133-
(is (= "abc*****hij" (shared/obfuscate "abcdefghij"))))
134-
135-
(testing "respect (bounded) preserve-num"
136+
(is (= "abc*****hij" (shared/obfuscate "abcdefghij"))))
137+
138+
(testing "respect (bounded) preserve-num"
136139
;; preserve-num smaller than half the length
137-
(is (= "a*****f" (shared/obfuscate "abcdef" :preserve-num 1)))
140+
(is (= "a*****f" (shared/obfuscate "abcdef" :preserve-num 1)))
138141
;; preserve-num larger than half the length is capped
139-
(is (= "abc*****def" (shared/obfuscate "abcdef" :preserve-num 10)))))
142+
(is (= "abc*****def" (shared/obfuscate "abcdef" :preserve-num 10)))))

0 commit comments

Comments
 (0)