| 1164 | } |
| 1165 | |
| 1166 | fn websocket_url(http_origin: &str, path: &str) -> String { |
| 1167 | if http_origin.starts_with("https://") { |
| 1168 | format!( |
| 1169 | "wss://{}{}", |
| 1170 | http_origin.trim_start_matches("https://"), |
| 1171 | path |
| 1172 | ) |
| 1173 | } else if http_origin.starts_with("http://") { |
| 1174 | format!("ws://{}{}", http_origin.trim_start_matches("http://"), path) |
| 1175 | } else { |
| 1176 | path.to_owned() |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | fn encode_target_id(app_id: &str, page_id: u64) -> String { |
| 1181 | format!("{}-{page_id}", hex::encode(app_id.as_bytes())) |