Hi Sean, On 28 Feb 2013, at 16:08, Sean P. DeNigris <[email protected]> wrote:
> What's the best way to do the following (non-working): > aZnUrl / 'path/segment/string'. > > Ways I thought of: > - Ugly: (url asString, 'path/segment/string') asZnUrl. > - Non-working: #addPathSegment: > - Tedious: url / 'path' / 'segment' / 'string' > > It seems like a common-enough thing to do, but I couldn't find a way that I > liked... > > Thanks, > Sean I am guessing you are lazy and want to type as little as possible, then the following are possible: 'http://endpoint.service.com:9090/v1' asZnUrl withPathSegments: '/foo/bar/resource.txt' asZnUrl pathSegments. 'http://endpoint.service.com:9090/v1' asZnUrl / #foo / #bar / 'resource.txt'. 'http://endpoint.service.com:9090/v1' asZnUrl withPathSegments: #(foo bar 'resource.txt'). There is an important difference between the internal and external representation of URL elements, #asZnUrl actually parses: 'http://endpoint.service.com:9090/v1' asZnUrl withPathSegments: '/foo%20bar' asZnUrl pathSegments. 'http://endpoint.service.com:9090/v1' asZnUrl / 'foo bar'. ZnUrl is not a general URL construction packages, the #/ #? and #? that I added for you help a bit, but they are limited. There is also #inContextOf: '/foo/bar/resource.txt' asZnUrl inContextOf: 'http://endpoint.service.com:9090/v1' asZnUrl but that does not merge paths (the v1 part is gone in the last expression). Maybe we could think about an algorithm or semantics to do path merging. Regards, Sven -- Sven Van Caekenberghe http://stfx.eu Smalltalk is the Red Pill
