Added fallback to absolute URL on failure to resolve CSS stylesheet @imports
This commit is contained in:
parent
11bbfc0851
commit
ef7ddcd434
12
src/utils.rs
12
src/utils.rs
|
@ -4,6 +4,7 @@ use self::base64::encode;
|
|||
use http::retrieve_asset;
|
||||
use regex::Regex;
|
||||
use url::{ParseError, Url};
|
||||
use std::io::{stderr, Write};
|
||||
|
||||
lazy_static! {
|
||||
static ref HAS_PROTOCOL: Regex = Regex::new(r"^[a-z0-9]+:").unwrap();
|
||||
|
@ -132,7 +133,16 @@ pub fn resolve_css_imports(
|
|||
opt_insecure,
|
||||
).map(|(a, _)| a),
|
||||
|
||||
}.unwrap_or_else(|_| EMPTY_STRING.clone());
|
||||
}.unwrap_or_else(|e| {
|
||||
writeln!(
|
||||
stderr(),
|
||||
"Warning: {}",
|
||||
e,
|
||||
).unwrap();
|
||||
|
||||
//If failed to resolve, replace with absolute URL
|
||||
embedded_url
|
||||
});
|
||||
|
||||
let replacement = format!("\"{}\"", &content);
|
||||
|
||||
|
|
Loading…
Reference in New Issue