MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / is_rewritable_metro_proxy_asset

Function is_rewritable_metro_proxy_asset

packages/server/src/devtools.rs:1014–1047  ·  view source on GitHub ↗
(asset_path: &str, content_type: Option<&str>)

Source from the content-addressed store, hash-verified

1012}
1013
1014fn is_rewritable_metro_proxy_asset(asset_path: &str, content_type: Option<&str>) -> bool {
1015 let path = asset_path
1016 .split_once('?')
1017 .map(|(path, _)| path)
1018 .unwrap_or(asset_path)
1019 .to_ascii_lowercase();
1020 if matches!(
1021 Path::new(&path)
1022 .extension()
1023 .and_then(|extension| extension.to_str()),
1024 Some("css" | "html" | "js" | "json" | "map" | "mjs")
1025 ) {
1026 return true;
1027 }
1028
1029 let Some(content_type) = content_type else {
1030 return false;
1031 };
1032 let media_type = content_type
1033 .split(';')
1034 .next()
1035 .unwrap_or("")
1036 .trim()
1037 .to_ascii_lowercase();
1038 media_type.starts_with("text/")
1039 || matches!(
1040 media_type.as_str(),
1041 "application/ecmascript"
1042 | "application/javascript"
1043 | "application/json"
1044 | "application/manifest+json"
1045 | "application/x-javascript"
1046 )
1047}
1048
1049fn rewrite_metro_proxy_text(port: u16, text: &str) -> String {
1050 let proxy_prefix = format!("/api/metro/{port}");

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected