Spec support
It'd be great if there was a way to validate/generate both EF and plain string URIs.
@valerauko, you mean validate that the URI matches the RFC?
It's already possible to generate both. Calling str on an EF URI will convert it to a plain string URI. And you can call uri on a string URI to create an EF URI.
Additionally, all of the URI manipulation functions work on plain strings as well.
Sorry, I meant more in the clojure.spec.alpha way.
I try to document my code with specs as much as possible and not being able to easily spec URLs is giving me trouble. I made a hacky spec/generator based on java.net.URI, but I can imagine it fitting in EF much better (and more complete)
So, exploding-fish is pretty liberal in what it will parse, so it will parse almost anything into a URI. For example:
user> (into {} (uri "fred is cool"))
{:scheme-relative "fred is cool", :path "fred is cool"}
absolute? checks to see if there's an authority in the URI. For example:
user> (absolute? (uri "fred is cool"))
false
user> (absolute? (uri "http://bob.com/fred is cool"))
true
It probably only makes sense to have a predicate to check for absolute URIs.
Would it make sense to have different predicates for Uri and String, or just a single check that will be valid for both Uri and String (and java.net.URI)? The exploding-fish URI functions work on all of those representations.
If you wanted to ensure it was a string URI, I suppose you could just check that it's a URI and that it's a String.
You're right, using your built-in predicates can solve some of my issues.
Do you plan to spec the library though?
I do plan on it, I'm just not sure when I'll get to it.