mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Avoid Uri.parse('')
This commit is contained in:
parent
4c71656f5d
commit
839a40edb3
|
@ -249,9 +249,10 @@ export class ExtensionLinter {
|
|||
private readPackageJsonInfo(folder: Uri, tree: JsonNode) {
|
||||
const engine = tree && findNodeAtLocation(tree, ['engines', 'vscode']);
|
||||
const repo = tree && findNodeAtLocation(tree, ['repository', 'url']);
|
||||
const uri = parseUri(repo.value);
|
||||
const info: PackageJsonInfo = {
|
||||
isExtension: !!(engine && engine.type === 'string'),
|
||||
hasHttpsRepository: !!(repo && repo.type === 'string' && repo.value && parseUri(repo.value).scheme.toLowerCase() === 'https')
|
||||
hasHttpsRepository: !!(repo && repo.type === 'string' && repo.value && uri && uri.scheme.toLowerCase() === 'https')
|
||||
};
|
||||
const str = folder.toString();
|
||||
const oldInfo = this.folderToPackageJsonInfo[str];
|
||||
|
@ -288,6 +289,9 @@ export class ExtensionLinter {
|
|||
|
||||
private addDiagnostics(diagnostics: Diagnostic[], document: TextDocument, begin: number, end: number, src: string, context: Context, info: PackageJsonInfo) {
|
||||
const uri = parseUri(src);
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
const scheme = uri.scheme.toLowerCase();
|
||||
|
||||
if (scheme && scheme !== 'https' && scheme !== 'data') {
|
||||
|
@ -347,7 +351,7 @@ function parseUri(src: string) {
|
|||
try {
|
||||
return Uri.parse(encodeURI(src));
|
||||
} catch (err) {
|
||||
return Uri.parse('');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue