Skip to content

Commit 949f8f3

Browse files
committed
use clean URL for status reporting
1 parent 30d2a06 commit 949f8f3

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/core.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ pub fn retrieve_asset(
540540
))
541541
}
542542
} else {
543-
print_error_message(&format!("{} (not found)", &url), options);
543+
print_error_message(&format!("{} (file not found)", &url), options);
544544

545545
// Provoke error
546546
Err(client.get("").send().unwrap_err())
@@ -550,7 +550,7 @@ pub fn retrieve_asset(
550550

551551
if cache.is_some() && cache.as_ref().unwrap().contains_key(&cache_key) {
552552
// URL is in cache, we get and return it
553-
print_info_message(&format!("{} (from cache)", &url), options);
553+
print_info_message(&format!("{} (from cache)", &cache_key), options);
554554

555555
Ok((
556556
cache.as_ref().unwrap().get(&cache_key).unwrap().0.to_vec(),
@@ -591,7 +591,10 @@ pub fn retrieve_asset(
591591
match client.get(url.as_str()).headers(headers).send() {
592592
Ok(response) => {
593593
if !options.ignore_errors && response.status() != reqwest::StatusCode::OK {
594-
print_error_message(&format!("{} ({})", &url, response.status()), options);
594+
print_error_message(
595+
&format!("{} ({})", &cache_key, response.status()),
596+
options,
597+
);
595598

596599
// Provoke error
597600
return Err(client.get("").send().unwrap_err());
@@ -600,9 +603,12 @@ pub fn retrieve_asset(
600603
let response_url: Url = response.url().clone();
601604

602605
if url.as_str() == response_url.as_str() {
603-
print_info_message(&format!("{}", &url), options);
606+
print_info_message(&cache_key.to_string(), options);
604607
} else {
605-
print_info_message(&format!("{} -> {}", &url, &response_url), options);
608+
print_info_message(
609+
&format!("{} -> {}", &cache_key, &response_url),
610+
options,
611+
);
606612
}
607613

608614
let new_cache_key: String = clean_url(response_url.clone()).to_string();
@@ -641,7 +647,7 @@ pub fn retrieve_asset(
641647
Ok((data, response_url, media_type, charset))
642648
}
643649
Err(error) => {
644-
print_error_message(&format!("{} ({})", &url, error), options);
650+
print_error_message(&format!("{} ({})", &cache_key, error), options);
645651

646652
Err(client.get("").send().unwrap_err())
647653
}

tests/cli/local_files.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ mod passing {
4141
"\
4242
{file}{cwd}/tests/_data_/basic/local-file.html\n\
4343
{file}{cwd}/tests/_data_/basic/local-style.css\n\
44-
{file}{cwd}/tests/_data_/basic/local-style-does-not-exist.css (not found)\n\
45-
{file}{cwd}/tests/_data_/basic/monolith.png (not found)\n\
44+
{file}{cwd}/tests/_data_/basic/local-style-does-not-exist.css (file not found)\n\
45+
{file}{cwd}/tests/_data_/basic/monolith.png (file not found)\n\
4646
{file}{cwd}/tests/_data_/basic/local-script.js\n\
4747
",
4848
file = file_url_protocol,

0 commit comments

Comments
 (0)