| 996 | } |
| 997 | |
| 998 | pub fn rewrite_metro_proxy_asset( |
| 999 | port: u16, |
| 1000 | asset_path: &str, |
| 1001 | content_type: Option<&str>, |
| 1002 | body: Vec<u8>, |
| 1003 | ) -> Vec<u8> { |
| 1004 | if !is_rewritable_metro_proxy_asset(asset_path, content_type) { |
| 1005 | return body; |
| 1006 | } |
| 1007 | |
| 1008 | match String::from_utf8(body) { |
| 1009 | Ok(text) => rewrite_metro_proxy_text(port, &text).into_bytes(), |
| 1010 | Err(error) => error.into_bytes(), |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | fn is_rewritable_metro_proxy_asset(asset_path: &str, content_type: Option<&str>) -> bool { |
| 1015 | let path = asset_path |