Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

back ~r Uri type with goog.Uri #16

Open
sgrove opened this issue Jul 9, 2015 · 4 comments
Open

back ~r Uri type with goog.Uri #16

sgrove opened this issue Jul 9, 2015 · 4 comments

Comments

@sgrove
Copy link

sgrove commented Jul 9, 2015

URIs as tagged values aren't very useful generally speaking, so right now I'm doing:

(deftype URIHandler []
    Object
  (tag [this v] "r")
  (rep [this v] (.toString v))
  (stringRep [this v] nil))

(def transit-reader
  (transit/reader :json
                  {:handlers
                   {"r" (fn [uri] (Uri. uri))}}))

(def transit-writer
  (transit/writer :json
                  {:handlers
                   {goog.Uri (URIHandler.)}}))

Would be nice to actually have this built into transit-cljs, though I'm not sure what the implications for running anywhere that goog.closure has a hard time reaching (self-hosting issue?).

@dustingetz
Copy link

dustingetz commented Oct 2, 2022

agree - cljs.core/uri? is defined and hardcoded to goog.Uri since 1.9. I understand that transit-js should neither depend on goog.Uri nor provide an explicit uri handler, but it seems like transit-cljs should align to clojurescript

@dustingetz
Copy link

dustingetz commented Oct 2, 2022

perhaps this is why:

(= (goog.Uri. "http://localhost:8080/a?b#c")
   (goog.Uri. "http://localhost:8080/a?b#c"))
=> false

(= (java.net.URI. "http://localhost:8080/a?b#c")
   (java.net.URI. "http://localhost:8080/a?b#c"))
=> true

@dustingetz
Copy link

Note transit-java and transit-clj also decline to read to java.net.URI (in disalignment with the language uri? predicate), instead reading as cct.Uri

@dustingetz
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants