lint code and update README.md
This commit is contained in:
parent
b13be1e0ce
commit
4091c5f627
|
@ -115,7 +115,7 @@ cat index.html | monolith -aIiFfcMv -b https://original.site/ - > result.html
|
||||||
- `-C`: Save document using custom `charset`
|
- `-C`: Save document using custom `charset`
|
||||||
- `-d`: Allow retrieving assets only from specified `domain(s)`
|
- `-d`: Allow retrieving assets only from specified `domain(s)`
|
||||||
- `-e`: Ignore network errors
|
- `-e`: Ignore network errors
|
||||||
- `-E`: Exclude all assets located within domains specified in whitelist
|
- `-E`: Avoid retrieving assets located within specified domains
|
||||||
- `-f`: Omit frames
|
- `-f`: Omit frames
|
||||||
- `-F`: Exclude web fonts
|
- `-F`: Exclude web fonts
|
||||||
- `-i`: Remove images
|
- `-i`: Remove images
|
||||||
|
|
|
@ -117,8 +117,8 @@ pub fn domain_is_within_domain(domain: &str, domain_to_match_against: &str) -> b
|
||||||
|
|
||||||
while i < l {
|
while i < l {
|
||||||
// Exit and return false if went out of bounds of domain to match against, and it didn't start with a dot
|
// Exit and return false if went out of bounds of domain to match against, and it didn't start with a dot
|
||||||
if domain_to_match_against_partials.len() < i + 1
|
if !domain_to_match_against_starts_with_a_dot
|
||||||
&& !domain_to_match_against_starts_with_a_dot
|
&& domain_to_match_against_partials.len() < i + 1
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
|
@ -135,10 +135,9 @@ pub fn domain_is_within_domain(domain: &str, domain_to_match_against: &str) -> b
|
||||||
domain_to_match_against_partials.get(i).unwrap()
|
domain_to_match_against_partials.get(i).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let parts_match = domain_to_match_against_starts_with_a_dot
|
let parts_match = domain_to_match_against_partial.eq_ignore_ascii_case(domain_partial);
|
||||||
|| domain_to_match_against_partial.eq_ignore_ascii_case(domain_partial);
|
|
||||||
|
|
||||||
if !parts_match {
|
if !parts_match && domain_to_match_against_partial.len() != 0 {
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,14 @@ mod failing {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn different_domain_is_not_within_dotted_domain() {
|
||||||
|
assert!(!utils::domain_is_within_domain(
|
||||||
|
"www.doodleoptimize.com",
|
||||||
|
".ycombinator.com"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_domain_can_be_within_empty_domain() {
|
fn no_domain_can_be_within_empty_domain() {
|
||||||
assert!(!utils::domain_is_within_domain("ycombinator.com", ""));
|
assert!(!utils::domain_is_within_domain("ycombinator.com", ""));
|
||||||
|
|
Loading…
Reference in New Issue