提交 4aaeb387 编写于 作者: M Martin Aeschlimann

[json] JSON Schema wrong path encoding #789

上级 9c4c52b0
......@@ -351,23 +351,23 @@ export class JSONSchemaService implements IJSONSchemaService {
schemaURL: url
});
}
return this.requestService.makeRequest({ url: url }).then(
request => {
var content = request.responseText;
if (!content) {
var errorMessage = nls.localize('json.schema.nocontent', 'Unable to load schema from \'{0}\': No content.', url) ;
var errorMessage = nls.localize('json.schema.nocontent', 'Unable to load schema from \'{0}\': No content.', toDisplayString(url));
return new UnresolvedSchema(<IJSONSchema> {}, [ errorMessage ]);
}
var schemaContent: IJSONSchema = {};
var jsonErrors = [];
schemaContent = Json.parse(content, errors);
var errors = jsonErrors.length ? [ nls.localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': {1}.', url, jsonErrors[0])] : [];
var errors = jsonErrors.length ? [ nls.localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': {1}.', toDisplayString(url), jsonErrors[0])] : [];
return new UnresolvedSchema(schemaContent, errors);
},
error => {
var errorMessage = nls.localize('json.schema.unabletoload', 'Unable to load schema from \'{0}\': {1}.', url, error.statusText || error.toString());
var errorMessage = nls.localize('json.schema.unabletoload', 'Unable to load schema from \'{0}\': {1}', toDisplayString(url), error.responseText || error.toString());
return new UnresolvedSchema(<IJSONSchema> {}, [ errorMessage ]);
}
);
......@@ -1562,4 +1562,16 @@ export class JSONSchemaService implements IJSONSchemaService {
});
}
}
function toDisplayString(url:string) {
try {
var uri = URI.parse(url);
if (uri.scheme === 'file') {
return uri.fsPath;
}
} catch (e) {
// ignore
}
return url;
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ export class WorkerRequestService extends BaseRequestService implements IThreadS
public makeRequest(options:http.IXHROptions):TPromise<http.IXHRResponse> {
let url = options.url;
if (!url) {
throw new Error('IRequestService.makeRequest: Url is required');
throw new Error('IRequestService.makeRequest: Url is required.');
}
// Support file:// in worker environment through XHR
......@@ -56,7 +56,7 @@ export class WorkerRequestService extends BaseRequestService implements IThreadS
return xhr; // loading resources locally returns a status of 0 which in WinJS is an error so we need to handle it here
}
return <any>Promise.wrapError(new Error(nls.localize('localFileNotFound', "File not found")));
return <any>Promise.wrapError({ status: 404, responseText: nls.localize('localFileNotFound', "File not found.")});
});
}
......
......@@ -80,7 +80,7 @@ export class RequestService extends BaseRequestService implements IThreadSynchro
public makeRequest(options: http.IXHROptions): TPromise<http.IXHRResponse> {
let url = options.url;
if (!url) {
throw new Error('IRequestService.makeRequest: Url is required');
throw new Error('IRequestService.makeRequest: Url is required.');
}
// Support file:// in native environment through XHR
......@@ -90,7 +90,7 @@ export class RequestService extends BaseRequestService implements IThreadSynchro
return xhr; // loading resources locally returns a status of 0 which in WinJS is an error so we need to handle it here
}
return <any>Promise.wrapError(new Error(nls.localize('localFileNotFound', "File not found")));
return <any>Promise.wrapError({ status: 404, responseText: nls.localize('localFileNotFound', "File not found.")});
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册