Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 05, 2016 URI parsing | ||||
---|---|---|---|---|
| ||||
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. |
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | 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 |
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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.
|
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | 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. |
October 06, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | 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 |
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | 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. |
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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
|
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | 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.
|
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | 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 |
October 05, 2016 Re: URI parsing | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | 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.
|
Copyright © 1999-2021 by the D Language Foundation