lambdaisland / uri

A pure Clojure/ClojureScript URI library
Mozilla Public License 2.0
243 stars 21 forks source link

different behavior on cljs vs clj for datomic uris #3

Closed dustingetz closed 7 years ago

dustingetz commented 7 years ago
$ boot -d lambdaisland/uri:1.1.0 repl
boot.user=> (require '[lambdaisland.uri :refer [uri join]])
boot.user=> (uri "datomic:free://datomic:4334/asdf")
#lambdaisland/uri "datomic:free://datomic:4334/asdf"

$ planck --classpath=`boot -d lambdaisland/uri:1.1.0 show -c`
cljs.user=> (require '[lambdaisland.uri :refer [uri join]])
cljs.user=> (uri "datomic:free://datomic:4334/root")
#lambdaisland.uri.URI{:scheme "datomic", :user nil, :password nil, :host nil, :port nil, :path "free://datomic:4334/root", :query nil, :fragment nil}

goog.Uri has the same problem. java.net.uri works. Perhaps Datomic is violating the uri spec?

plexus commented 7 years ago

The problem is that how to interpret a url depends on the "scheme", (ie. the protocol, the part before the :). For http/https/mailto/ftp/data etc there's a standard (an RFC) how to interpret the rest of the uri. For datomic: there is no spec (RFC).

Lambdaisland/uri is meant to work with http/https/ftp, or other schemes that follow the same structure. This does not include datomic unfortunately.

On Sep 28, 2017 8:04 PM, "Dustin Getz" notifications@github.com wrote:

$ boot -d lambdaisland/uri:1.1.0 repl boot.user=> (require '[lambdaisland.uri :refer [uri join]]) boot.user=> (uri "datomic:free://datomic:4334/asdf")

lambdaisland/uri "datomic:free://datomic:4334/asdf"

$ planck --classpath=boot -d lambdaisland/uri:1.1.0 show -c cljs.user=> (require '[lambdaisland.uri :refer [uri join]]) cljs.user=> (uri "datomic:free://datomic:4334/root")

lambdaisland.uri.URI{:scheme "datomic", :user nil, :password nil, :host nil, :port nil, :path "free://datomic:4334/root", :query nil, :fragment nil}

goog.Uri has the same problem. java.net.uri works. Perhaps Datomic is violating the uri spec?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lambdaisland/uri/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB91IiQn4hslaR1zjpS_VqR_u6O--AYks5sm9-ngaJpZM4PnqZU .

plexus commented 7 years ago

As a side note, I don't think there's a difference in parsing here, the resulting URI object is just printed differently. Seems the custom printer doesn't work with Planck.

You can try this in clojure to see how it's been parsed : (into {} (uri "datomic:..."))

Because the : is not followed by // the rest of the uri is interpreted as a relative path, which is per the http uri RFC.

On Sep 28, 2017 9:55 PM, "Arne Brasseur" arne.brasseur@gmail.com wrote:

The problem is that how to interpret a url depends on the "scheme", (ie. the protocol, the part before the :). For http/https/mailto/ftp/data etc there's a standard (an RFC) how to interpret the rest of the uri. For datomic: there is no spec (RFC).

Lambdaisland/uri is meant to work with http/https/ftp, or other schemes that follow the same structure. This does not include datomic unfortunately.

On Sep 28, 2017 8:04 PM, "Dustin Getz" notifications@github.com wrote:

$ boot -d lambdaisland/uri:1.1.0 repl boot.user=> (require '[lambdaisland.uri :refer [uri join]]) boot.user=> (uri "datomic:free://datomic:4334/asdf")

lambdaisland/uri "datomic:free://datomic:4334/asdf"

$ planck --classpath=boot -d lambdaisland/uri:1.1.0 show -c cljs.user=> (require '[lambdaisland.uri :refer [uri join]]) cljs.user=> (uri "datomic:free://datomic:4334/root")

lambdaisland.uri.URI{:scheme "datomic", :user nil, :password nil, :host nil, :port nil, :path "free://datomic:4334/root", :query nil, :fragment nil}

goog.Uri has the same problem. java.net.uri works. Perhaps Datomic is violating the uri spec?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lambdaisland/uri/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB91IiQn4hslaR1zjpS_VqR_u6O--AYks5sm9-ngaJpZM4PnqZU .

dustingetz commented 7 years ago

Ok, thanks.

dustingetz commented 7 years ago

Is this new uri type something I might be able to teach the library about?

plexus commented 7 years ago

Not really, the parsing is done with a regex which is hard coded. You could use the source as inspiration for your own version.

What exactly are you trying to do? What you could do is chop off the datomic: part and parse the rest, at least that part seems to have a similar structure as a http uri.

On Sep 29, 2017 18:25, "Dustin Getz" notifications@github.com wrote:

Is this new uri type something I might be able to teach the library about?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/lambdaisland/uri/issues/3#issuecomment-333172973, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB91AV0VlBcCc1UwmvXikRgWy4Nii5Nks5snRndgaJpZM4PnqZU .