Skip to main content

served_path

Function served_path 

Source
pub fn served_path(source: &str, bytes: &[u8]) -> String
Expand description

The URL path the platform serves the asset file source (a normalised assets/… key) with content bytes at: /_assets/<stem>.<hash>.<ext>, where <hash> is the content’s FNV-1a 64 (crate::contract::fnv1a64_hex) and <stem>/<ext> are the file name’s, split at its last . (no .<ext> when it has none).

Only the file name is kept, not its folders: the hash already tells two files apart, and the same bytes under the same name are one served file, however many declarations name them. Any character outside [A-Za-z0-9._-] becomes -, so .url never needs percent-encoding. Reproducible: it depends only on the name and the bytes.