Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access json-schema.org with https, prepare 5.3.8 #211

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-json-languageservice",
"version": "5.3.7",
"version": "5.3.8",
"description": "Language service for JSON",
"main": "./lib/umd/jsonLanguageService.js",
"typings": "./lib/umd/jsonLanguageService",
Expand Down
3 changes: 3 additions & 0 deletions src/services/jsonSchemaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ export class JSONSchemaService implements IJSONSchemaService {
const errorMessage = l10n.t('Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
return this.promise.resolve(new UnresolvedSchema(<JSONSchema>{}, [errorMessage]));
}
if (url.startsWith('http://json-schema.org/')) {
url = 'https' + url.substring(4); // always access json-schema.org with https. See https://github.com/microsoft/vscode/issues/195189
}
return this.requestService(url).then(
content => {
if (!content) {
Expand Down
25 changes: 25 additions & 0 deletions src/test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1976,4 +1976,29 @@ suite('JSON Schema', () => {

});

test('access json-schema.org with https', async function () {
const httpUrl = "http://json-schema.org/schema";
const httpsUrl = "https://json-schema.org/schema";

const schemas: { [uri: string]: JSONSchema } = {
[httpsUrl]: {
type: 'object',
properties: {
bar: {
const: 3
}
}
}
};
const accesses: string[] = [];
const schemaRequestService = newMockRequestService(schemas, accesses);

const ls = getLanguageService({ workspaceContext, schemaRequestService });

const testDoc = toDocument(JSON.stringify({ $schema: httpUrl, bar: 2 }));
let validation = await ls.doValidation(testDoc.textDoc, testDoc.jsonDoc);
assert.deepStrictEqual(validation.map(v => v.message), ['Value must be 3.']);
assert.deepStrictEqual([httpsUrl], accesses);
});

});