MCPcopy Create free account
hub / github.com/emwalker/digraph / parse_url

Function parse_url

backend/src/http/repo_url.rs:124–151  ·  view source on GitHub ↗
(input: &str)

Source from the content-addressed store, hash-verified

122}
123
124fn parse_url(input: &str) -> Result<(url::Url, String)> {
125 let url = url::Url::parse(input)?;
126
127 if !url.has_host() {
128 return Err(Error::UrlParse(format!("invalid url: {input}")));
129 }
130
131 let host = url
132 .host_str()
133 .ok_or(Error::UrlParse(format!("no host: {input}")))?;
134 let filter = make_filter(host);
135 let query: Vec<(_, _)> = url.query_pairs().filter(filter).collect();
136
137 let mut url2 = url.clone();
138 url2.set_query(None);
139
140 for pair in query {
141 url2.query_pairs_mut()
142 .append_pair(&pair.0.to_string()[..], &pair.1.to_string()[..]);
143 }
144
145 match host {
146 "mail.google.com" => {}
147 _ => url2.set_fragment(None),
148 }
149
150 Ok((url2, host.to_owned()))
151}
152
153#[cfg(test)]
154mod tests {

Callers 1

parseMethod · 0.85

Calls 2

parseFunction · 0.85
make_filterFunction · 0.85

Tested by

no test coverage detected