diff --git a/lib/schema-provider.ts b/lib/schema-provider.ts index 3198cf5..8079d53 100644 --- a/lib/schema-provider.ts +++ b/lib/schema-provider.ts @@ -1,5 +1,6 @@ import * as _ from "lodash"; var fetch: (url: string) => Rx.IPromise = require('node-fetch'); +var stripBom = require("strip-bom"); import {Observable} from "rx"; interface IResult { @@ -81,8 +82,11 @@ class SchemaProvider { private getSchemas() { //http://schemastore.org/api/json/catalog.json - return Observable.fromPromise(fetch('http://schemastore.org/api/json/catalog.json') - .then(res => res.json())) + return Observable.fromPromise( + fetch('http://schemastore.org/api/json/catalog.json') + .then(res => res.text()) + .then(txt => JSON.parse(stripBom(txt))) + ) .map(({ schemas }) => { _.each(schemas, schema => { this.addSchema(schema); diff --git a/package.json b/package.json index b56a50b..44e7744 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "react": "^0.13.3", "rx": "^2.5.3", "semver": "^5.0.0", + "strip-bom": "^3.0.0", "through2": "^2.0.0", "tsd": "~0.6.1", "typescript": "^1.5.0-beta"