const INDEX: &[u8] = include_bytes!("assets/rmux-share/index.html");
const CSS: &[u8] = include_bytes!("assets/rmux-share/_astro/index.D2bSaP4U.css");
const JS: &[u8] = include_bytes!(
"assets/rmux-share/_astro/index.astro_astro_type_script_index_0_lang.CdYCpIGm.js"
);
const WASM: &[u8] =
include_bytes!("assets/rmux-share/_astro/rmux_web_crypto_wasm_bg.C8R0tHIf.wasm");
const EMPTY_SVG: &[u8] = b"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1\" height=\"1\"/>";
pub fn file(path: &str) -> Option<(&'static str, &'static [u8])> {
match path {
"/term" | "/term/" => Some(("text/html; charset=utf-8", INDEX)),
"/_astro/index.D2bSaP4U.css" => Some(("text/css; charset=utf-8", CSS)),
"/_astro/index.astro_astro_type_script_index_0_lang.CdYCpIGm.js" => {
Some(("application/javascript; charset=utf-8", JS))
}
"/_astro/rmux_web_crypto_wasm_bg.C8R0tHIf.wasm" => Some(("application/wasm", WASM)),
"/rose-dark.svg" | "/rose-light.svg" => Some(("image/svg+xml", EMPTY_SVG)),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_asset_the_page_names_is_served() {
let page = std::str::from_utf8(INDEX).expect("utf-8");
let mut named = 0;
for piece in page.split('"') {
if piece.starts_with("/_astro/") {
assert!(file(piece).is_some(), "{piece} is named but not served");
named += 1;
}
}
assert_eq!(
named, 2,
"the page should name one stylesheet and one script"
);
let js = std::str::from_utf8(JS).expect("utf-8");
assert!(
js.contains("/_astro/rmux_web_crypto_wasm_bg.C8R0tHIf.wasm"),
"the script loads a WebAssembly module this does not serve"
);
assert!(file("/_astro/../index.html").is_none());
}
}