tremor-runtime icon indicating copy to clipboard operation
tremor-runtime copied to clipboard

`url` stdlib module

Open mfelsche opened this issue 1 year ago • 6 comments

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:

  • definitions: https://github.com/tremor-rs/tremor-runtime/blob/main/tremor-script/lib/std/url.tremor
  • implementation: https://github.com/tremor-rs/tremor-runtime/blob/main/tremor-script/src/std_lib/url.rs

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);
# ...

mfelsche avatar Jan 17 '23 13:01 mfelsche