Skip to content

Commit b3665b9

Browse files
committed
better fix for microsoft#58694
1 parent bac5061 commit b3665b9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

extensions/extension-editing/src/extensionLinter.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface TokenAndPosition {
4040
interface PackageJsonInfo {
4141
isExtension: boolean;
4242
hasHttpsRepository: boolean;
43+
repository: Uri;
4344
}
4445

4546
export class ExtensionLinter {
@@ -253,7 +254,8 @@ export class ExtensionLinter {
253254
const uri = repo && parseUri(repo.value);
254255
const info: PackageJsonInfo = {
255256
isExtension: !!(engine && engine.type === 'string'),
256-
hasHttpsRepository: !!(repo && repo.type === 'string' && repo.value && uri && uri.scheme.toLowerCase() === 'https')
257+
hasHttpsRepository: !!(repo && repo.type === 'string' && repo.value && uri && uri.scheme.toLowerCase() === 'https'),
258+
repository: uri
257259
};
258260
const str = folder.toString();
259261
const oldInfo = this.folderToPackageJsonInfo[str];
@@ -289,13 +291,13 @@ export class ExtensionLinter {
289291
}
290292

291293
private addDiagnostics(diagnostics: Diagnostic[], document: TextDocument, begin: number, end: number, src: string, context: Context, info: PackageJsonInfo) {
292-
const uri = parseUri(src, document.uri.toString());
294+
const uri = parseUri(src, info.repository ? info.repository.toString() : document.uri.toString());
293295
if (!uri) {
294296
return;
295297
}
296298
const scheme = uri.scheme.toLowerCase();
297299

298-
if (scheme && scheme !== 'https' && scheme !== 'data') {
300+
if (scheme !== 'https' && scheme !== 'data') {
299301
const range = new Range(document.positionAt(begin), document.positionAt(end));
300302
diagnostics.push(new Diagnostic(range, httpsRequired, DiagnosticSeverity.Warning));
301303
}
@@ -305,7 +307,7 @@ export class ExtensionLinter {
305307
diagnostics.push(new Diagnostic(range, dataUrlsNotValid, DiagnosticSeverity.Warning));
306308
}
307309

308-
if (!scheme && !info.hasHttpsRepository) {
310+
if (!info.hasHttpsRepository) {
309311
const range = new Range(document.positionAt(begin), document.positionAt(end));
310312
let message = (() => {
311313
switch (context) {
@@ -345,7 +347,7 @@ function endsWith(haystack: string, needle: string): boolean {
345347
}
346348
}
347349

348-
function parseUri(src: string, base?: string, retry: boolean = true) {
350+
function parseUri(src: string, base?: string, retry: boolean = true): Uri {
349351
try {
350352
let url = new URL(src, base);
351353
return Uri.parse(url.toString());

0 commit comments

Comments
 (0)