Skip to content

Commit f1ee3d4

Browse files
pweaverctron
authored andcommitted
Changes filehash to always be 16 characters
Filehash is a u64. Most of the time it is 16 characters, but if the leading digit is a 0, it becomes 15 characters. e.g. 0x0fffffffffffffff -> fffffffffffffff instead of 0fffffffffffffff. This changes it to format with leading zeros. Which makes writing code to extracting the hashes more predictible.
1 parent e0016e5 commit f1ee3d4

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/pipelines/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl AssetFile {
328328

329329
let file_name = if with_hash {
330330
format!(
331-
"{}-{:x}.{}",
331+
"{}-{:0>16x}.{}",
332332
&self.file_stem.to_string_lossy(),
333333
seahash::hash(bytes.as_ref()),
334334
&self.ext.as_deref().unwrap_or_default()

src/pipelines/sass.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ impl Sass {
151151
let hash = seahash::hash(css.as_bytes());
152152

153153
let file_name = if self.cfg.filehash {
154-
format!("{}-{:x}.css", &self.asset.file_stem.to_string_lossy(), hash)
154+
format!(
155+
"{}-{:0>16x}.css",
156+
&self.asset.file_stem.to_string_lossy(),
157+
hash
158+
)
155159
} else {
156160
temp_target_file_name
157161
};

src/pipelines/tailwind_css.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ impl TailwindCss {
131131
// dir.
132132
let hash = seahash::hash(css.as_bytes());
133133
let file_name = if self.cfg.filehash {
134-
format!("{}-{:x}.css", &self.asset.file_stem.to_string_lossy(), hash)
134+
format!(
135+
"{}-{:0>16x}.css",
136+
&self.asset.file_stem.to_string_lossy(),
137+
hash
138+
)
135139
} else {
136140
file_name
137141
};

src/pipelines/tailwind_css_extra.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ impl TailwindCssExtra {
131131
// dir.
132132
let hash = seahash::hash(css.as_bytes());
133133
let file_name = if self.cfg.filehash {
134-
format!("{}-{:x}.css", &self.asset.file_stem.to_string_lossy(), hash)
134+
format!(
135+
"{}-{:0>16x}.css",
136+
&self.asset.file_stem.to_string_lossy(),
137+
hash
138+
)
135139
} else {
136140
file_name
137141
};

0 commit comments

Comments
 (0)