url-cleaner-site

Crates.iourl-cleaner-site
lib.rsurl-cleaner-site
version0.6.2
sourcesrc
created_at2024-11-25 22:05:49.450537
updated_at2024-11-25 22:05:49.450537
descriptionA basic HTTP server and userscript to make using URL Cleaner in a browser easier.
homepage
repositoryhttps://github.com/Scripter17/url-cleaner-site
max_upload_size
id1460851
size137,530
James C. Wise (Scripter17)

documentation

README

URL Cleaner Site

/!\ THIS IS NOT HARDENED AGAINST MALICIOUS INPUT /!\

A user could send a job of the form {"urls": ["https://bit.ly/abcdef", ... x1000], "params_diff": {"read_cache": false}} to cause a very long running job.

This particular example also has the side effect of possibly having bit.ly (or any other shortlink site) block the IP URL Cleaner Site is running on.

In the future, there will be a way to block/limit the params_diff field but, as its existence is extremely useful, it will not be removed by default.

Details

A basic HTTP server and userscript to allow automatically applying URL Cleaner to every URL on every webpage you visit.

It binds to 127.0.0.1:9149 by default and http://localhost:9149/clean takes a simple job of the following form:

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BulkJob {
    #[serde(alias = "urls", alias = "configs")]
    pub job_configs: Vec<JobConfig>,
    #[serde(default)]
    pub params_diff: Option<ParamsDiff>
}

and returns a response Result<CleaningSuccess, CleaningError> which is defined as

pub struct CleaningSuccess {
    pub urls: Vec<Result<Result<Url, StringDoJobError>, StringMakeJobError>>
}

pub struct StringMakeJobError {
    pub message: String,
    pub variant: String
}

pub struct StringDoJobError {
    pub message: String,
    pub variant: String
}

pub struct CleaningError {
    pub status: u16,
    pub reason: Option<&'static str>
}

It is intended to be byte-for-byte identical to the equivalent invocation of URL Cleaner in JSON mode.
This way if one wants to transition from URL Cleaner to URL Cleaner Site (or vice versa) there's very little code to change.

Commit count: 28

cargo fmt