Added fallback to absolute URL on failure to resolve CSS stylesheet @imports

This commit is contained in:
Emi Simpson 2019-12-05 18:37:37 -05:00
parent 11bbfc0851
commit ef7ddcd434
No known key found for this signature in database
GPG Key ID: 68FAB2E2E6DFC98B
1 changed files with 11 additions and 1 deletions

View File

@ -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);