Skip to content

Commit ec8de4e

Browse files
committed
git: better uri parsing error message
1 parent 5fdfdd7 commit ec8de4e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

extensions/git/src/uri.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,21 @@ export function isGitUri(uri: Uri): boolean {
1717
}
1818

1919
export function fromGitUri(uri: Uri): GitUriParams {
20-
return qs.parse(uri.query) as any;
20+
const result = qs.parse(uri.query) as any;
21+
22+
if (!result) {
23+
throw new Error('Invalid git URI: empty query');
24+
}
25+
26+
if (typeof result.path !== 'string') {
27+
throw new Error('Invalid git URI: missing path');
28+
}
29+
30+
if (typeof result.ref !== 'string') {
31+
throw new Error('Invalid git URI: missing ref');
32+
}
33+
34+
return result;
2135
}
2236

2337
export interface GitUriOptions {

0 commit comments

Comments
 (0)