W3C home > Mailing lists > Public > public-rdfjs@w3.org > July 2014

Re: banana-rdf libs for scala-js

From: <henry.story@bblfish.net>
Date: Wed, 2 Jul 2014 17:33:22 +0200
Cc: Adrian Gschwend <ktk@netlabs.org>, "public-rdfjs@w3.org" <public-rdfjs@w3.org>
Message-Id: <91E85890-F14A-4482-A40D-82B14A3D54B4@bblfish.net>
To: Austin William Wright <aaa@bzfx.net>

On 30 Jun 2014, at 19:19, Austin William Wright <aaa@bzfx.net> wrote:

> The 'iri' module has most of the features that the 'url' module already has, however the implementation varies in that it's implemented using the vocabulary found in RFC 3986. Node.js uses invented names like 'pathname' and 'search', the official ABNF productions are named 'path' and 'query', respectively.
> Additionally, I aim to implement RFC 3986 URI reference resolution to the letter. Node.js's url.resolve() call operates in some peculiar ways that the core developers are unwilling to correct.
> I may opt to change the public API in the future, right now everything is a function, and many of the calls (like query()) return a leading character like "?" if not null, which might not be the easiest to use. (This is the same interface that I forked from webr3.) Remember to use semver semantics and depend on "~1". I don't have any particular ideas though, if you have any ideas, feel free to throw up an issue on GitHub.
> The functionality not found within 'url' is the ability to convert a URI to an IRI and vice-versa. E.g., converting the following IRI (encoded here as an ECMAScript/JavaScript string):
>     "http://example.com/\u2713"
> Into the following URI (that contains only 7-bit characters):
>     <http://example.com/%E2%9C%93>
> HTML, XML, Turtle, RDF, and most formats that allow Unicode actually use IRIs, but HTTP and other network protocols only use URIs, and so have to be converted.
> Note that a URI is also a legal IRI, this means that any IRI with unicode characters has multiple IRIs that identify the same resource.

Indeed I prefer the naming.
One thing I don't like with the node Url class is that it does not deal with default ports correctly, and it looks like
this library follows suite. This means that one has to write special code for equality testing. 
It also looks like it would be useful to have a canonical method to transform URLs into a canonical format
eg new IRI("http://bblfish.net/people/henry/../jane#me) .canonical == new IRI("("http://bblfish.net/people/jane#me) 
should be true

In Scala there is a very nice library called spray [1] which has a Uri class [2] that does all of that
very nicely ( even if there is an issue with relative Uri resolution ). See the test cases


Porting that to ScalaJS is pretty close to being feasible. It just requires parboiled2 to be ported to
ScalaJs which it has nearly been ( and then adapt spray to parboiled2 as it is using the previous 
version currently ).


[1] http://spray.io/documentation/1.2.1/spray-http/
[2] https://github.com/spray/spray/blob/master/spray-http/src/main/scala/spray/http/Uri.scala
[3] https://github.com/spray/spray/blob/master/spray-http/src/test/scala/spray/http/UriSpec.scala

> Austin.
> On Mon, Jun 30, 2014 at 2:31 AM, Adrian Gschwend <ktk@netlabs.org> wrote:
> On 30.06.14 11:27, Ruben Verborgh wrote:
> > I recently saw https://github.com/Acubed/node-iri pass by on this list;
> > however, I think that Node's url module does what you need:
> > http://nodejs.org/api/url.html.
> I had a look at node-iri as well but was a bit confused what the
> difference is to the node URL module (except structure of it). Austin
> could you give some comments on that?
> regards
> Adrian
> --
> Adrian Gschwend
> @ netlabs.org
> ktk [a t] netlabs.org
> -------
> Open Source Project
> http://www.netlabs.org

Social Web Architect
Received on Wednesday, 2 July 2014 15:40:52 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:48:21 UTC