jsonnet icon indicating copy to clipboard operation
jsonnet copied to clipboard

Add std.parseUrl

Open jgustie opened this issue 5 years ago • 2 comments

Having a std.parseUrl(str) that returns a JSON object with "scheme", "host", "path", "query" and "fragment" fields would be useful for generating configurations where some applications accept parts of the URL as individual fields.

I suppose "host" could be more complicated, e.g. it may be useful to have "host" and "port" separated out, it may be useful to have "hostport" as a single string, have "port" always populated with the default for the "scheme", etc.

jgustie avatar Apr 09 '19 21:04 jgustie

With this sort of thing it's good to first have a working implementation in Jsonnet.

FYI I've been working for some time now on a small library which makes parsing things in Jsonnet easier in general.

This RFC describes in detail what can be inside https://tools.ietf.org/html/rfc3986. Splitting the thing once we can assume it's correct is quite easy. The tricky part is making is validating it and making it, compliant in all weird cases. But I guess even quite permissive splitting could be useful.

sbarzowski avatar Apr 10 '19 09:04 sbarzowski

I'd love to see this moving on :)

toloco avatar Dec 12 '22 15:12 toloco