Skip to content

Commit 389cc1b

Browse files
plexusbbatsov
authored andcommitted
Make URLCoercable coerce directly to string
We expect a string in the response, and this allows us to take a shorter path for several types, and to bypass coerction to java.net.URL.
1 parent 68f9153 commit 389cc1b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/cider/nrepl/middleware/content_type.clj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@
5656
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5757

5858
(defprotocol URLCoercable
59-
(as-url [o]))
59+
(as-url-string [o]))
6060

6161
(extend-protocol URLCoercable
6262
Path
63-
(as-url [^Path p]
64-
(.. p normalize toUri toURL))
63+
(as-url-string [^Path p]
64+
(.. p normalize toUri toString))
6565

6666
File
67-
(as-url [^File f]
68-
(.. f getCanonicalFile toURI toURL))
67+
(as-url-string [^File f]
68+
(.. f getCanonicalFile toURI toString))
6969

7070
URI
71-
(as-url [^URI u]
72-
(.. u toURL))
71+
(as-url-string [^URI u]
72+
(.toString u))
7373

7474
URL
75-
(as-url [^URL u]
76-
u))
75+
(as-url-string [^URL u]
76+
(.toString u)))
7777

7878
(defn external-body-response
7979
"Partial response map having an external-body content-type referring to the given URL.
@@ -82,7 +82,7 @@
8282
[value]
8383
{:content-type ["message/external-body"
8484
{"access-type" "URL"
85-
"URL" (.toString ^URL (as-url value))}]
85+
"URL" (as-url-string value)}]
8686
:body ""})
8787

8888
(defmulti content-type-response

0 commit comments

Comments
 (0)