jsonnet
jsonnet copied to clipboard
Add std.parseUrl
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.
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.
I'd love to see this moving on :)