MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / parse_mcp_resource_url

Method parse_mcp_resource_url

crates/opencode-session/src/prompt.rs:629–651  ·  view source on GitHub ↗
(url: &str)

Source from the content-addressed store, hash-verified

627 }
628
629 fn parse_mcp_resource_url(url: &str) -> Option<(String, String)> {
630 let parsed = url::Url::parse(url).ok()?;
631 if parsed.scheme() != "mcp" {
632 return None;
633 }
634
635 let client_name = parsed.host_str()?.to_string();
636 let mut uri = parsed.path().trim_start_matches('/').to_string();
637 if let Some(query) = parsed.query() {
638 if !query.is_empty() {
639 if !uri.is_empty() {
640 uri.push('?');
641 }
642 uri.push_str(query);
643 }
644 }
645
646 if uri.is_empty() {
647 return None;
648 }
649
650 Some((client_name, uri))
651 }
652
653 fn filename_from_url(url: &str) -> String {
654 if let Ok(parsed) = url::Url::parse(url) {

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.80
queryMethod · 0.45

Tested by

no test coverage detected