Closed awwright closed 10 years ago
Thanks for pointing this out. :)
I've released a fix as v0.1.2.
Could you give me some examples of the kind of things you're parsing?
I think there's some optimisation that could be done for simple cases like /{category}/{id}/
, etc.
For now I'm just parsing stuff like {+subject}
(if the URI is already in the database), or /user/{uid}
to provide a user. Really the only obstacle is the one I described on the JSON Schema mailing list, where the "uid" variable is supposed to be returned as an integer, but currently, this fromURI function has no way of coercing the value.
My use cases may eventually become rather complex, in such a way that will have to be integrated in with JSON Hyper-Schema, I think. It will be stuff like /blog/{created.YYYY}/{created.MM}/{created.DD}/{title.URLFriendly}
. Especially due to the last part (modifying the title to a 'URL friendly' version like replacing spaces with dashes), the way to handle this may be to generate the desired URL using this one-way URI Template, and store that as a database field, and do a reverse-lookup using e.g. /blog/{+subject}
.
There's one instance of
console.log
in the library, in fromUri, which prints debugging information to the console. This should be removed.(This library's from-URI resolving seems to be better than the one I was designing, so I'm adopting this. I'm calling fromUri many times per HTTP request, so this is important for optimization.)
This is also problematic in Web browsers where
console
may be not be a symbol.