Re: URL API

On 08/07/2013 21:16 , Domenic Denicola wrote:
>> One thing that's still a bit unclear is how to expose path
>> segments. We could expose the segments as array, we could expose a
>> special segments object so you can change the URL that way, or
>> something else. Suggestions welcome.
>
> I would be tempted to just leave it out and make people do the work
> manually of manipulating `pathname`, since I can't think of a great
> answer. Or are there potential footguns we want to avoid, e.g. if
> people naively did `url.pathname.split("/")` or `url.pathname =
> mySegments.join("/")` they wouldn't get what you expect? I guess
> there are some encoding issues...

People will naïvely split and join on "/" while forgetting about the 
leading "/". They'll also forget about %-escaping, which they should 
except that if setting the string directly you can't tell if a "/" in it 
was intended as a separator or not.

An abstraction would certainly be helpful here.

-- 
Robin Berjon - http://berjon.com/ - @robinberjon

Received on Monday, 8 July 2013 20:03:09 UTC