Re: URI parsing

2016-10-05 Thread John Carter via Digitalmars-d

On Wednesday, 5 October 2016 at 10:19:08 UTC, John C wrote:

In fact, I'm surprised there isn't one in Phobos yet.


Different John C here :-)

I'm sadly forced to do a bit of C++ recently and found they don't 
have one in the standard library either...


That feels archaic and out of the 1980's compared to the 
ecosystem around Ruby or Perl.


The downstream fallout of refusing to just "pick one", is that 
packages depending on such functionality each "roll their own", 
and users have to provide compatibility shims all over the place.


Part of the success of Ruby has been it comes "With Batteries 
included".


Re: URI parsing

2016-10-05 Thread Nick Sabalausky via Digitalmars-d

On 10/05/2016 06:19 AM, John C wrote:

What packages do people use when they want to parse URIs? I rolled my
own but it's incomplete and as it's a fairly common need there must be
one out there? In fact, I'm surprised there isn't one in Phobos yet.


IIRC there's one in vibe I used not too long ago.


Re: URI parsing

2016-10-05 Thread Eugene Wissner via Digitalmars-d

On Wednesday, 5 October 2016 at 10:19:08 UTC, John C wrote:
What packages do people use when they want to parse URIs? I 
rolled my own but it's incomplete and as it's a fairly common 
need there must be one out there? In fact, I'm surprised there 
isn't one in Phobos yet.


I also wrote a function for extended url parsing based on php 
source code. it is in dlib: https://github.com/gecko0307/dlib

dlib.network.url


Re: URI parsing

2016-10-05 Thread ketmar via Digitalmars-d
On Wednesday, 5 October 2016 at 12:14:06 UTC, Jonathan M Davis 
wrote:
a mess. From what I recall, it's not even possible to parse a 
URL in a completely unambiguous manner. *sigh*


yeah. everything after scheme is highly dependent of scheme 
itself, so your parser should know about various schemes and 
their syntax. and even with "http:" it sometimes a guesswork.


Re: URI parsing

2016-10-05 Thread Jonathan M Davis via Digitalmars-d
On Thursday, October 06, 2016 00:13:03 rikki cattermole via Digitalmars-d 
wrote:
> On 06/10/2016 12:12 AM, Basile B. wrote:
> > It's not easy to make a true URI implementation, by "true" I mean
> > "conform" with https://tools.ietf.org/html/rfc3986.
>
> Yeah the spec is quite nasty.

Yeah, like _far_ too many of the RFCs relating to the web, it's a mess. From
what I recall, it's not even possible to parse a URL in a completely
unambiguous manner. *sigh*

- Jonathan M Davis



Re: URI parsing

2016-10-05 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 5 October 2016 at 10:19:08 UTC, John C wrote:

What packages do people use when they want to parse URIs?


I did one based on the regex found in the RFC for my cgi and http 
libs.


cgi version (more complete)
https://github.com/adamdruppe/arsd/blob/master/cgi.d#L2163

http version (just what i needed for handling relative links in 
html)

https://github.com/adamdruppe/arsd/blob/master/http2.d#L114


If you just need to parse a complete uri though, go ahead and use 
the regex from the RFC. My thing is more about making uris based 
on other uris for handling those links.


Re: URI parsing

2016-10-05 Thread rikki cattermole via Digitalmars-d

On 06/10/2016 12:12 AM, Basile B. wrote:

On Wednesday, 5 October 2016 at 10:19:08 UTC, John C wrote:

What packages do people use when they want to parse URIs? I rolled my
own but it's incomplete and as it's a fairly common need there must be
one out there? In fact, I'm surprised there isn't one in Phobos yet.


It's not easy to make a true URI implementation, by "true" I mean
"conform" with https://tools.ietf.org/html/rfc3986.

But for the URL subset there's url.d: https://code.dlang.org/packages/urld.


Yeah the spec is quite nasty.
Luckily nobody uses Gopher anymore!

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



Re: URI parsing

2016-10-05 Thread Basile B. via Digitalmars-d

On Wednesday, 5 October 2016 at 10:19:08 UTC, John C wrote:
What packages do people use when they want to parse URIs? I 
rolled my own but it's incomplete and as it's a fairly common 
need there must be one out there? In fact, I'm surprised there 
isn't one in Phobos yet.


It's not easy to make a true URI implementation, by "true" I mean 
"conform" with https://tools.ietf.org/html/rfc3986.


But for the URL subset there's url.d: 
https://code.dlang.org/packages/urld.


Re: URI parsing

2016-10-05 Thread John C via Digitalmars-d
On Wednesday, 5 October 2016 at 10:28:44 UTC, rikki cattermole 
wrote:
I developed[0] with the hopes that at some point in the future 
I could bring that over to Phobos. But before that I'm waiting 
for allocators to be moved out of experimental first.


[0] 
https://github.com/rikkimax/alphaPhobos/blob/master/source/std/experimental/uri.d


Looks good, thanks.


Re: URI parsing

2016-10-05 Thread rikki cattermole via Digitalmars-d

On 05/10/2016 11:19 PM, John C wrote:

What packages do people use when they want to parse URIs? I rolled my
own but it's incomplete and as it's a fairly common need there must be
one out there? In fact, I'm surprised there isn't one in Phobos yet.


I developed[0] with the hopes that at some point in the future I could 
bring that over to Phobos. But before that I'm waiting for allocators to 
be moved out of experimental first.


[0] 
https://github.com/rikkimax/alphaPhobos/blob/master/source/std/experimental/uri.d


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



URI parsing

2016-10-05 Thread John C via Digitalmars-d
What packages do people use when they want to parse URIs? I 
rolled my own but it's incomplete and as it's a fairly common 
need there must be one out there? In fact, I'm surprised there 
isn't one in Phobos yet.