MCPcopy Create free account
hub / github.com/TeamPiped/piped-proxy / localize_url

Function localize_url

src/utils.rs:57–75  ·  view source on GitHub ↗
(url: &str, host: &str)

Source from the content-addressed store, hash-verified

55}
56
57pub fn localize_url(url: &str, host: &str) -> String {
58 if url.starts_with("https://") {
59 let url = Url::parse(url).unwrap();
60 let host = url.host().unwrap().to_string();
61
62 let mut query = url.query_pairs().into_owned().collect::<BTreeMap<_, _>>();
63
64 query.insert("host".to_string(), host.clone());
65
66 return finalize_url(url.path(), query);
67 } else if url.ends_with(".m3u8") || url.ends_with(".ts") {
68 let mut query = BTreeMap::new();
69 query.insert("host".to_string(), host.to_string());
70
71 return finalize_url(url, query);
72 }
73
74 url.to_string()
75}
76
77pub fn escape_xml(raw: &str) -> Cow<'_, str> {
78 if !raw.contains(&['<', '>', '&', '\'', '"'][..]) {

Callers 1

indexFunction · 0.85

Calls 1

finalize_urlFunction · 0.85

Tested by

no test coverage detected