Skip to content

Commit 2907ea6

Browse files
authored
access json-schema.org with https, prepare 5.3.8 (#211)
1 parent 5496aee commit 2907ea6

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-json-languageservice",
3-
"version": "5.3.7",
3+
"version": "5.3.8",
44
"description": "Language service for JSON",
55
"main": "./lib/umd/jsonLanguageService.js",
66
"typings": "./lib/umd/jsonLanguageService",

src/services/jsonSchemaService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ export class JSONSchemaService implements IJSONSchemaService {
390390
const errorMessage = l10n.t('Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
391391
return this.promise.resolve(new UnresolvedSchema(<JSONSchema>{}, [errorMessage]));
392392
}
393+
if (url.startsWith('http://json-schema.org/')) {
394+
url = 'https' + url.substring(4); // always access json-schema.org with https. See https://github.com/microsoft/vscode/issues/195189
395+
}
393396
return this.requestService(url).then(
394397
content => {
395398
if (!content) {

src/test/schema.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,4 +1976,29 @@ suite('JSON Schema', () => {
19761976

19771977
});
19781978

1979+
test('access json-schema.org with https', async function () {
1980+
const httpUrl = "http://json-schema.org/schema";
1981+
const httpsUrl = "https://json-schema.org/schema";
1982+
1983+
const schemas: { [uri: string]: JSONSchema } = {
1984+
[httpsUrl]: {
1985+
type: 'object',
1986+
properties: {
1987+
bar: {
1988+
const: 3
1989+
}
1990+
}
1991+
}
1992+
};
1993+
const accesses: string[] = [];
1994+
const schemaRequestService = newMockRequestService(schemas, accesses);
1995+
1996+
const ls = getLanguageService({ workspaceContext, schemaRequestService });
1997+
1998+
const testDoc = toDocument(JSON.stringify({ $schema: httpUrl, bar: 2 }));
1999+
let validation = await ls.doValidation(testDoc.textDoc, testDoc.jsonDoc);
2000+
assert.deepStrictEqual(validation.map(v => v.message), ['Value must be 3.']);
2001+
assert.deepStrictEqual([httpsUrl], accesses);
2002+
});
2003+
19792004
});

0 commit comments

Comments
 (0)