Handle relative paths (#58694)

This commit is contained in:
Christof Marti 2018-09-26 15:19:30 +02:00
parent ece59d53dc
commit 92cc41ebd0

View file

@ -291,23 +291,24 @@ export class ExtensionLinter {
}
private addDiagnostics(diagnostics: Diagnostic[], document: TextDocument, begin: number, end: number, src: string, context: Context, info: PackageJsonInfo) {
const hasScheme = /^\w[\w\d+.-]*:/.test(src);
const uri = parseUri(src, info.repository ? info.repository.toString() : document.uri.toString());
if (!uri) {
return;
}
const scheme = uri.scheme.toLowerCase();
if (scheme !== 'https' && scheme !== 'data') {
if (hasScheme && scheme !== 'https' && scheme !== 'data') {
const range = new Range(document.positionAt(begin), document.positionAt(end));
diagnostics.push(new Diagnostic(range, httpsRequired, DiagnosticSeverity.Warning));
}
if (scheme === 'data') {
if (hasScheme && scheme === 'data') {
const range = new Range(document.positionAt(begin), document.positionAt(end));
diagnostics.push(new Diagnostic(range, dataUrlsNotValid, DiagnosticSeverity.Warning));
}
if (!info.hasHttpsRepository) {
if (!hasScheme && !info.hasHttpsRepository) {
const range = new Range(document.positionAt(begin), document.positionAt(end));
let message = (() => {
switch (context) {