On Tue, May 19, 2015 at 10:49 PM, Sven Van Caekenberghe <s...@stfx.eu> wrote: > > > I made the following commits: > This does not change the current default behaviour, but it makes it a lot > easier to work with relative references: >
Cool. Now just a passing thought. The original term URL is from RFC1738, which is obsolete. RFC3986 says "The term 'Uniform Resource Locator' (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism." I don't completely follow that, but maybe there is use for a ZnUri class that provides broader semantics than ZnUrl. > ZnUrl image + 'foo.txt' > > => "file:///Users/sven/Develop/Smalltalk/foo.txt" > > You just have to choose an appropriate base URL: > > 'postgresql://user:password@localhost:5432/default' asUrl + 'test' > > => "postgresql://user:password@localhost:5432/test" > > However, when you override the host, the port (actually the whole > authority) is reset as well (according to my interpretation of the RFC > anyway), that is why I added #portIfAbsent: > > 'postgresql://production/user-db' asUrl portIfAbsent: 5432 > > => 5432 > > I also added #asFileUrl to help in the common case of interpreting any > scheme as referring to a file path. After that conversion, one will > probably want to do an #asFileReference. > > > Looking through Zinc I notice that the schemes are symbols. Any plans > to make these classes? To maybe(?) make it easier to extend to other > schemes (http://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml) > ? Or do you consider that outside the scope of Zinc ? > > Well, it is a 'problem area' (design/implementation wise). Your suggestion > makes sense though: to make the schemes objects so that they could > implement specific behaviour (rather than making many subclasses of ZnUrl). > I will think about this, thanks for the idea ! > > > Perhaps an advantage of a Scheme class is that it might make it easier for a "postgresql" to define a default port. btw, The part of RFC3986 that sparked this thought was this... "URI scheme specifications can define opaque identifiers by disallowing use of slash characters, question mark characters, and the URIs "scheme:." and "scheme:..". cheers -ben