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

Function rewrite_absolute_metro_paths

packages/server/src/devtools.rs:1067–1096  ·  view source on GitHub ↗
(text: &str, proxy_prefix: &str)

Source from the content-addressed store, hash-verified

1065}
1066
1067fn rewrite_absolute_metro_paths(text: &str, proxy_prefix: &str) -> String {
1068 let mut rewritten = String::with_capacity(text.len());
1069 let mut index = 0;
1070 while index < text.len() {
1071 let remaining = &text[index..];
1072 let metro_path = ["/rozenite/", "/debugger-frontend/"]
1073 .into_iter()
1074 .find(|prefix| remaining.starts_with(prefix));
1075 if let Some(metro_path) = metro_path {
1076 let previous = text[..index].chars().next_back();
1077 if previous
1078 .map(is_absolute_metro_path_boundary)
1079 .unwrap_or(true)
1080 {
1081 rewritten.push_str(proxy_prefix);
1082 rewritten.push_str(metro_path);
1083 index += metro_path.len();
1084 continue;
1085 }
1086 }
1087
1088 let character = remaining
1089 .chars()
1090 .next()
1091 .expect("remaining text is non-empty");
1092 rewritten.push(character);
1093 index += character.len_utf8();
1094 }
1095 rewritten
1096}
1097
1098fn is_absolute_metro_path_boundary(character: char) -> bool {
1099 character.is_ascii_whitespace()

Callers 1

rewrite_metro_proxy_textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected