-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function to parse URIs #2989
Comments
This is an auto-generated commit with a Zed dependency update. The Zed PR brimdata/super#3080, authored by @nwt, has been merged. add Zed url_parse function Closes brimdata/super#2989.
This is an auto-generated commit with a Zed dependency update. The Zed PR brimdata/super#3080, authored by @nwt, has been merged. add Zed url_parse function Closes brimdata/super#2989.
This is an auto-generated commit with a Zed dependency update. The Zed PR brimdata/super#3080, authored by @nwt, has been merged. add Zed url_parse function Closes brimdata/super#2989.
Verified in Zed commit fdca08a. Let's take an example Grafana URL that has lots of stuff to parse.
Calling the new function to parse it:
Note that this is one of the first times a Zed function is returning a
If you try to access a key that isn't in the map, you get a warning, but it's otherwise a no-op.
It should also be noted that the Brim app is presenting map values pretty crudely at the moment (brimdata/zui#1245) However, as something in Zed, this is definitely ready to show off to the user in the community that requested the functionality. Thanks @nwt! |
Repro is with Zed commit 59dc184.
A community user recently asked:
Regexp group support (#2093) has the potential to help here when we implement it. For now, I pointed out the existence of the
split()
function and slice operator that can accomplish much of this. For example:No doubt this could be taken even further by using the sequence operator to break out the entries in the
pairs
array into separate fields.However, having shown this, I was also aware that there's probably escaping or other complexity that could make this approach break with some URIs. That made me search & find Go libraries like https://pkg.go.dev/net/url#example-URL.Query that purport to do this heavy lifting for us. Since URI manipulation is something that may come up frequently for our users, it might be beneficial for Zed to provide a URI-specific parsing function that returns a nested record containing the fully-parsed data.
The text was updated successfully, but these errors were encountered: