Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async resovleSchema(url: string): Promise {
const uri = URI.parse(url);
if (uri.scheme === 'file') {
return new Promise((resolve, reject) => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.readFile(uri.fsPath, 'UTF-8', (err, result) => {
err ? reject('') : resolve(result.toString());
});
});
}
try {
const response = await xhr({ url, followRedirects: 5 });
return response.responseText;
} catch (error) {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
}
}
async resovleSchema(url) {
const uri = vscode_uri_1.default.parse(url);
if (uri.scheme === 'file') {
return new Promise((resolve, reject) => {
fs.readFile(uri.fsPath, 'UTF-8', (err, result) => {
err ? reject('') : resolve(result.toString());
});
});
}
try {
const response = await request_light_1.xhr({ url, followRedirects: 5 });
return response.responseText;
} catch (error) {
return Promise.reject(
error.responseText || request_light_1.getErrorStatusDescription(error.status) || error.toString()
);
}
}
// protected resolveCompletion(item: CompletionItem): Thenable {
protected async resolveSchema(url: string): Promise {
const uri = URI.parse(url);
if (uri.scheme === 'file') {
return new Promise((resolve, reject) => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
readFile(uri.fsPath, 'UTF-8', (err, result) => {
err ? reject('') : resolve(result.toString());
});
});
}
try {
const response = await xhr({ url, followRedirects: 5 });
return response.responseText;
} catch (error) {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
}
}
protected async resovleSchema(url: string): Promise {
const uri = URI.parse(url);
if (uri.scheme === 'file') {
return new Promise((resolve, reject) => {
fs.readFile(uri.fsPath, 'UTF-8', (err, result) => {
err ? reject('') : resolve(result.toString());
});
});
}
try {
const response = await xhr({ url, followRedirects: 5 });
return response.responseText;
} catch (error) {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
}
}
protected async resovleSchema(url: string): Promise {
const uri = URI.parse(url);
if (uri.scheme === 'file') {
return new Promise((resolve, reject) => {
fs.readFile(uri.fsPath, 'UTF-8', (err, result) => {
err ? reject('') : resolve(result.toString());
});
});
}
try {
const response = await xhr({ url, followRedirects: 5 });
return response.responseText;
} catch (error) {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
}
}
const response = await xhr(
Object.assign(
{
url: uri,
followRedirects: 5,
headers: { "Accept-Encoding": "gzip, deflate" }
},
options
)
)
return response.responseText
} catch (error) {
sendException(error)
return (
error.responseText ||
getErrorStatusDescription(error.status) ||
error.toString()
)
}
}
}, (error) => {
return Promise.reject(error.responseText || request_light_1.getErrorStatusDescription(error.status) || error.toString());
});
};
protected async resolveSchema(url: string): Promise {
const uri = URI.parse(url);
if (uri.scheme === 'file') {
return new Promise((resolve, reject) => {
fs.readFile(uri.fsPath, 'UTF-8', (err, result) => {
err ? reject('') : resolve(result.toString());
});
});
}
try {
const response = await xhr({ url, followRedirects: 5 });
return response.responseText;
}
catch (error) {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
}
}
(error: XHRResponse) => Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString()));
}
}, (error: XHRResponse) => {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
});
}