feat(p10-1a-2): route .rs files to MediaType::Code(rust)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 17:17:36 +00:00
parent 7a6a24ad10
commit a531dc37dc

View File

@@ -34,6 +34,10 @@ pub(crate) fn media_type_for(path: &Path) -> MediaType {
"flac" => MediaType::Audio(AudioType::Flac),
"ogg" => MediaType::Audio(AudioType::Ogg),
// p10-1A-2: Rust is the only code lang activated in 1A. Other
// recognized code langs stay Other until their phase (1B+).
"rs" => MediaType::Code("rust".to_string()),
// Empty string (no extension) and any other extension: bucket as
// Other and let downstream extractors decide if they support it.
_ => MediaType::Other(ext),
@@ -71,6 +75,17 @@ mod tests {
);
}
#[test]
fn rust_files_map_to_media_code_rust() {
assert_eq!(
media_type_for(Path::new("crates/kebab-core/src/lib.rs")),
MediaType::Code("rust".to_string())
);
// non-Rust code extensions stay Other in 1A
assert_eq!(media_type_for(Path::new("a/b.py")), MediaType::Other("py".to_string()));
assert_eq!(media_type_for(Path::new("Cargo.toml")), MediaType::Other("toml".to_string()));
}
#[test]
fn unknown_and_missing_extension() {
assert_eq!(