declutter/
lib.rs

1//! Declutter url lists
2//!
3//! * Match extensions, i.e.: `html`, `js`, `php`
4//! * Filter extensionless
5//! * Filter extensions, i.e.: `jpg`, `css`, `pdf`
6//! * Filter keywords, i.e.: `bootstrap`, `jquery`, `node_modules`
7//!
8//! See [`Budget`] to configure the behavior and [`Declutter`] to get started.
9
10pub struct Budget<'b> {
11    /// Does urls without a file extension be allowed
12    ///
13    /// The following urls are considered as extensionless:
14    ///
15    /// 1. `https://localhost`
16    /// 2. `https://localhost/`
17    /// 3. `https://localhost/hello`
18    ///
19    /// # Example
20    ///
21    /// ```rust
22    /// true
23    /// ```
24    allow_extensionless: bool,
25
26    /// Allow only the given file extensions
27    ///
28    /// # Example
29    ///
30    /// ```rust
31    /// Some(&["html", "php", "js"])
32    /// ```
33    allow_extensions: Option<&'b [&'b str]>,
34
35    /// Deny the given file extensions
36    ///
37    /// # Example
38    ///
39    /// ```rust
40    /// Some(&["css", "scss", "webp", "ico", "jpg", "jpeg", "png", "svg", "bmp", "gif", "eot", "mp3", "mp4", "mkv", "avi", "wav", "tif", "tiff", "ttf", "otf", "woff", "woff2"])
41    /// ```
42    deny_extensions: Option<&'b [&'b str]>,
43
44    /// Filter urls based on a keyword list.
45    ///
46    /// # Example
47    ///
48    /// ```rust
49    /// Some(&["bootstrap", "jquery", "node_modules"])
50    /// ```
51    deny_keywords: Option<&'b [&'b str]>,
52}
53
54/// Run matchers and filterers against urls
55///
56/// # See Also
57///
58/// [`Budget`]
59pub struct Declutter<'b> {
60    budget: Budget<'b>,
61}