this post was submitted on 19 Jul 2024
24 points (90.0% liked)

Rust Programming

8190 readers
40 users here now

founded 5 years ago
MODERATORS
 

This would entail:

  • Pulling in the ClearUrls rules as a git submodule.
  • Reading / transforming the json there into Rust structs.
  • Creating a Rust crate that runs a .clean(input_url) -> String

Lemmy issue: https://github.com/LemmyNet/lemmy/issues/4905

top 6 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 4 months ago (1 children)

@dessalines Did something similar last night. Might take a look into using ClearURLs instead: https://github.com/diogotcorreia/alt-urls-discord-bot

[–] [email protected] 2 points 4 months ago

Nice! Ya that could be made very multi-purpose.

[–] BB_C 4 points 4 months ago (1 children)

Looks trivial and easy to automate.
I possibly would have done it if they had a test suite.
But unless I didn't look hard enough, they have no tests at all (other than linting)!

[–] [email protected] 2 points 4 months ago* (last edited 4 months ago)

Yep, it'd be a pretty small library. I'm not sure if they generate those JSON rules from somewhere else, but either way they could be converted to defined rust objects as part of a build process.

This might be helpful: https://github.com/oxidecomputer/typify

[–] [email protected] 3 points 3 months ago (1 children)

I just released a crate doing exactly that: https://crates.io/crates/clearurls

Let me know if if fits your need or you need anything else. Issues and PRs welcome.

[–] [email protected] 2 points 3 months ago

Whoa nice! I'll check it out and see how we can integrate it into lemmy.