tremor-rs / tremor-runtime

Main Tremor Project Rust Codebase
https://www.tremor.rs
Apache License 2.0
842 stars 127 forks source link

`url` stdlib module #2181

Open mfelsche opened 1 year ago

mfelsche commented 1 year ago

Describe the problem you are trying to solve

Parsing urls as strings is hard, manipulating and evaluating them is even harder, although it doesn't have to be.

Describe the solution you'd like

We would like to have a stdlib module for tremor-script that makes it possible to parse a url structure from a string and construct a url from parts and modify existing urls.

Those functions would be implemented in the existing std::url module:

Example script (just my imagination going wild, could be implemented totally differently):

use std;
let url_str = "https://example.org/path?query=foo&snot&badger=1&badger=2#fragment";
let url = std::url::parse(url_str);
url.scheme == "https";
url.host == "example.org";
url.path = "/path";
url.query = "query=foo&snot&badger=1&badger=2";
url.fragment = "fragment";
let query = std::url::parse_query(url.query);
# ...
glokta1 commented 1 year ago

Hey, I'd like to take a stab at this :D

mfelsche commented 1 year ago

Cool, shall I assign you to this issue?

Do you need any guidance? Please check those links above first and see if they are helpful for you.

Here is an example on how to conduct tests on your implementations: https://github.com/tremor-rs/tremor-runtime/blob/main/tremor-cli/tests/stdlib/std/all.tremor#L630-L643

glokta1 commented 1 year ago

Hey @mfelsche , sorry I'm a little stretched thin right now, which I didn't anticipate when I commented on this issue :sweat_smile:. I won't be able to work on this for the time. Feel free to assign it to my good friend @0xquark. He says he can work on this.

mfelsche commented 1 year ago

Thank you for your transparency here @glokta1 . Lets have a thumbs up from @0xquark on this comment and the assignment will happen :)

0xquark commented 1 year ago

Thanks @glokta1 for follow-up. This issues seems something i can work on as i am still learning rust and this would help me understand things in a much better way, @mfelsche let's make this fix happen!

Licenser commented 1 year ago

Awesome, the rust part isn't too tough on this, the steps to take is:

1) find a library that does the encoding (the URL one we already use will likely be a good starting point ;) ) 2) build the datastructures 3) export & expose the function (Matthias already linked the relevant files) 4) win :)

If you get stuck at any point feel free to ping or drop a message in the discord!