mirror of
https://github.com/getzola/zola
synced 2024-11-10 06:14:19 +00:00
Reduced cachebust fingerprint to be more reasonable (#2074)
* Reduced cachebust fingerprint to be more reasonable.
This commit is contained in:
parent
0c5ffa8963
commit
84d057fa1e
2 changed files with 6 additions and 4 deletions
|
@ -777,7 +777,7 @@ fn can_ignore_markdown_content() {
|
|||
fn can_cachebust_static_files() {
|
||||
let (_, _tmp_dir, public) = build_site("test_site");
|
||||
assert!(file_contains!(public, "index.html",
|
||||
"<link href=\"https://replace-this-with-your-url.com/site.css?h=83bd983e8899946ee33d0fde18e82b04d7bca1881d10846c769b486640da3de9\" rel=\"stylesheet\">"));
|
||||
"<link href=\"https://replace-this-with-your-url.com/site.css?h=83bd983e8899946ee33d\" rel=\"stylesheet\">"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -135,7 +135,9 @@ impl TeraFn for GetUrl {
|
|||
Some(compute_hash::<Sha256>(contents, false))
|
||||
}) {
|
||||
Some(hash) => {
|
||||
permalink = format!("{}?h={}", permalink, hash);
|
||||
let fullhash = format!("{}", hash);
|
||||
let shorthash = &fullhash[..20]; // 2^-80 chance of false positive
|
||||
permalink = format!("{}?h={}", permalink, shorthash);
|
||||
}
|
||||
None => {
|
||||
return Err(format!(
|
||||
|
@ -302,7 +304,7 @@ title = "A title"
|
|||
let mut args = HashMap::new();
|
||||
args.insert("path".to_string(), to_value("app.css").unwrap());
|
||||
args.insert("cachebust".to_string(), to_value(true).unwrap());
|
||||
assert_eq!(static_fn.call(&args).unwrap(), "http://a-website.com/app.css?h=572e691dc68c3fcd653ae463261bdb38f35dc6f01715d9ce68799319dd158840");
|
||||
assert_eq!(static_fn.call(&args).unwrap(), "http://a-website.com/app.css?h=572e691dc68c3fcd653a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -333,7 +335,7 @@ title = "A title"
|
|||
args.insert("path".to_string(), to_value("app.css").unwrap());
|
||||
args.insert("trailing_slash".to_string(), to_value(true).unwrap());
|
||||
args.insert("cachebust".to_string(), to_value(true).unwrap());
|
||||
assert_eq!(static_fn.call(&args).unwrap(), "http://a-website.com/app.css/?h=572e691dc68c3fcd653ae463261bdb38f35dc6f01715d9ce68799319dd158840");
|
||||
assert_eq!(static_fn.call(&args).unwrap(), "http://a-website.com/app.css/?h=572e691dc68c3fcd653a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue