57
*/
58
export function fromAgentClientUri(agentClientUri: URI): URI {
60
>
const query = agentClientUri.query || undefined;
61
>
const fragment = agentClientUri.fragment || undefined;
62
>
63
>
const schemeEnd = path.indexOf('/', 1);
64
>
if (schemeEnd === -1) {
65
return URI.from({ scheme: 'file', path, query, fragment });
66
}
68
>
let originalScheme = path.substring(1, schemeEnd);
69
>
const isOpaque = originalScheme.endsWith('!');
70
>
if (isOpaque) {
71
originalScheme = originalScheme.substring(0, originalScheme.length - 1);
72
}
74
>
const authorityEnd = path.indexOf('/', schemeEnd + 1);
75
>
if (authorityEnd === -1) {
76
const originalAuthority = path.substring(schemeEnd + 1);
77
return URI.from({ scheme: originalScheme, authority: originalAuthority === '-' ? '' : originalAuthority, path: '/', query, fragment });
78
}
80
>
let originalAuthority = path.substring(schemeEnd + 1, authorityEnd);
81
>
if (originalAuthority === '-') {
82
originalAuthority = '';
83
}
85
>
let originalPath = path.substring(authorityEnd);
86
>
if (isOpaque) {
87
// Drop the synthetic leading '/' we inserted in toAgentClientUri.
88
originalPath = originalPath.substring(1);
89
}
91
>
return URI.from({
92
>
scheme: originalScheme,
93
>
authority: originalAuthority || undefined,
94
>
path: originalPath,
95
>
query,
96
>
fragment,
97
>
});
98
>
}