DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/UriComponents/
FromUrl.rs1use serde_json::{Value, json};
10
11use crate::IPC::UriComponents::StampMidUri;
12
13pub fn Fn(Url:&str) -> Value {
14 if let Some(Rest) = Url.strip_prefix("file://") {
15 let (Authority, Path) = match Rest.find('/') {
16 Some(0) => ("", Rest),
17
18 Some(Index) => (&Rest[..Index], &Rest[Index..]),
19
20 None => ("", ""),
21 };
22
23 return StampMidUri::Fn(json!({
24 "scheme": "file",
25 "authority": Authority,
26 "path": Path,
27 "query": "",
28 "fragment": "",
29 }));
30 }
31
32 if let Some((Scheme, PathPart)) = Url.split_once(':') {
33 let Trimmed = PathPart.trim_start_matches("//");
34
35 let (Authority, Path) = match Trimmed.find('/') {
36 Some(0) => ("", Trimmed),
37
38 Some(Index) => (&Trimmed[..Index], &Trimmed[Index..]),
39
40 None => ("", Trimmed),
41 };
42
43 return StampMidUri::Fn(json!({
44 "scheme": Scheme,
45 "authority": Authority,
46 "path": Path,
47 "query": "",
48 "fragment": "",
49 }));
50 }
51
52 StampMidUri::Fn(json!({
53 "scheme": "file",
54 "authority": "",
55 "path": Url,
56 "query": "",
57 "fragment": "",
58 }))
59}