Skip to content

Commit a273181

Browse files
Improvements as per code review
Co-authored-by: katrinafyi <39479354+katrinafyi@users.noreply.github.com>
1 parent 03e4f08 commit a273181

File tree

7 files changed

+19
-28
lines changed

7 files changed

+19
-28
lines changed

lychee-bin/src/formatters/response/emoji.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod emoji_tests {
7070
let body = mock_response_body!(Status::Excluded, "https://example.com/not-checked");
7171
assert_eq!(
7272
formatter.format_response(&body),
73-
"👻 https://example.com/not-checked | This is due to your 'exclude' and 'include' values"
73+
"👻 https://example.com/not-checked | This is due to your 'exclude' values"
7474
);
7575
}
7676

lychee-bin/src/formatters/response/plain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mod plain_tests {
5555
let body = mock_response_body!(Status::Excluded, "https://example.com/not-checked");
5656
assert_eq!(
5757
formatter.format_response(&body),
58-
"[EXCLUDED] https://example.com/not-checked | This is due to your 'exclude' and 'include' values"
58+
"[EXCLUDED] https://example.com/not-checked | This is due to your 'exclude' values"
5959
);
6060
}
6161

lychee-bin/src/formatters/response/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mod task_tests {
4545
let body = mock_response_body!(Status::Excluded, "https://example.com/not-checked");
4646
assert_eq!(
4747
formatter.format_response(&body),
48-
"- [ ] [EXCLUDED] https://example.com/not-checked | This is due to your 'exclude' and 'include' values"
48+
"- [ ] [EXCLUDED] https://example.com/not-checked | This is due to your 'exclude' values"
4949
);
5050
}
5151

lychee-bin/src/formatters/stats/junit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ mod tests {
117117
<system-out>https://github.com/mre/idiomatic-rust-doesnt-exist-man (at 1:1) | 404 Not Found</system-out>
118118
</testcase>
119119
<testcase name="Excluded https://excluded.org/" time="0.042" file="https://example.com/">
120-
<skipped message="https://excluded.org/ | This is due to your &apos;exclude&apos; and &apos;include&apos; values"/>
121-
<system-out>https://excluded.org/ | This is due to your &apos;exclude&apos; and &apos;include&apos; values</system-out>
120+
<skipped message="https://excluded.org/ | This is due to your &apos;exclude&apos; values"/>
121+
<system-out>https://excluded.org/ | This is due to your &apos;exclude&apos; values</system-out>
122122
</testcase>
123123
<testcase name="Successful https://success.org/" time="1.000" file="https://example.com/">
124124
<system-out>https://success.org/</system-out>

lychee-bin/tests/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ The config file should contain every possible key for documentation purposes."
15611561
"[IGNORED] {unsupported_url} (at 1:1) | Unsupported: Failed to create HTTP request client: builder error for url (slack://user)"
15621562
)))
15631563
.stderr(contains(format!(
1564-
"[EXCLUDED] {excluded_url} (at 2:1) | This is due to your 'exclude' and 'include' values\n"
1564+
"[EXCLUDED] {excluded_url} (at 2:1) | This is due to your 'exclude' values\n"
15651565
)));
15661566

15671567
// The cache file should be empty, because the only checked URL is

lychee-lib/src/client.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -533,40 +533,31 @@ impl Client {
533533
ErrorKind: From<E>,
534534
{
535535
let Request {
536-
ref mut uri,
536+
mut uri,
537537
credentials,
538538
source,
539539
span,
540540
..
541541
} = request.try_into()?;
542542

543-
let remapping = self.remap(uri)?;
544-
545-
if self.is_excluded(uri) {
546-
return Ok(Response::new(
547-
uri.clone(),
548-
Status::Excluded,
549-
source.into(),
550-
span,
551-
None,
552-
));
553-
}
554-
555543
let start = std::time::Instant::now(); // Measure check time
544+
let remapping = self.remap(&mut uri)?;
556545

557-
let mut status = match uri.scheme() {
546+
let status = match uri.scheme() {
547+
_ if self.is_excluded(&uri) => Status::Excluded,
558548
_ if uri.is_tel() => Status::Excluded, // We don't check tel: URIs
559-
_ if uri.is_file() => self.check_file(uri).await,
560-
_ if uri.is_mail() => self.check_mail(uri).await,
561-
_ => self.check_website(uri, credentials).await?,
549+
_ if uri.is_file() => self.check_file(&uri).await,
550+
_ if uri.is_mail() => self.check_mail(&uri).await,
551+
_ => self.check_website(&uri, credentials).await?,
562552
};
563553

564-
if let Some(remapping) = remapping {
565-
status = Status::Remapped(Box::new(status), remapping);
566-
}
554+
let status = match remapping {
555+
Some(remapping) => Status::Remapped(Box::new(status), remapping),
556+
None => status,
557+
};
567558

568559
Ok(Response::new(
569-
uri.clone(),
560+
uri,
570561
status,
571562
source.into(),
572563
span,

lychee-lib/src/types/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Status {
161161
Status::RequestError(e) => e.error().details(),
162162
Status::UnknownMailStatus(reason) => reason.clone(),
163163
Status::Timeout(_) => "Request timed out".into(),
164-
Status::Excluded => "This is due to your 'exclude' and 'include' values".into(),
164+
Status::Excluded => "This is due to your 'exclude' values".into(),
165165
Status::Unsupported(_) | Status::Cached(_) | Status::UnknownStatusCode(_) => {
166166
self.to_string()
167167
}

0 commit comments

Comments
 (0)