MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / extract_origin

Function extract_origin

crates/openshell-cli/src/auth.rs:216–222  ·  view source on GitHub ↗

Extract the origin (scheme + host) from a gateway endpoint URL. For example, `https://8080-3vdegyusg.brevlab.com/some/path` → `https://8080-3vdegyusg.brevlab.com`. Returns `None` if the URL cannot be parsed.

(gateway_endpoint: &str)

Source from the content-addressed store, hash-verified

214/// For example, `https://8080-3vdegyusg.brevlab.com/some/path` → `https://8080-3vdegyusg.brevlab.com`.
215/// Returns `None` if the URL cannot be parsed.
216fn extract_origin(gateway_endpoint: &str) -> Option<String> {
217 // Split on "://" to get scheme and the rest.
218 let (scheme, rest) = gateway_endpoint.split_once("://")?;
219 // The host (with optional port) is everything before the first '/'.
220 let host = rest.split('/').next().unwrap_or(rest);
221 Some(format!("{scheme}://{host}"))
222}
223
224#[derive(Deserialize)]
225struct CallbackPayload {

Callers 1

run_callback_serverFunction · 0.85

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected