voca_rs icon indicating copy to clipboard operation
voca_rs copied to clipboard

Encode/decode URI?

Open chipsenkbeil opened this issue 3 years ago • 2 comments

I didn't see anything at a glance, but wanted to check if there's any support to encode/decode URIs with this library. I know some other Rust libraries exist that do this, but I'm already using voca for html escaping and also need URI encoding. Would love to maintain a single dependency instead of multiple if it makes sense.

Example in JavaScript is the encodeURI function.

At the moment, I'm using percent-encoding to achieve this.

chipsenkbeil avatar May 16 '21 03:05 chipsenkbeil

Hi @chipsenkbeil! Thank you for using my crate! 😸 I agree; that might be a valuable addition to it. Have you reviewed this crate https://crates.io/crates/pct-str? It's pretty small (9Kb) and does exactly what you want? Does it fit you? Or maybe this one https://crates.io/crates/urlencoding? (5Kb) Otherwise, could you please provide test cases that you are interested in?

a-merezhanyi avatar May 16 '21 18:05 a-merezhanyi

@e1r0nd, I'm using percent-encoding right now, which is slightly smaller than pct-str. Both of these along with urlencoding appear to do the same thing, which is good as this shouldn't be too hard. 😄

For me, the specific use case is that I parse documents for links, but these links can also reference local files that have spaces in their paths. I first encode all spaces as %20 (as well as other relevant characters) and then parse using uriparse-rs.

chipsenkbeil avatar May 17 '21 00:05 chipsenkbeil

No movements on this, so it is closed.

a-merezhanyi avatar Jun 06 '23 08:06 a-merezhanyi