diff --git a/package.json b/package.json index 4663004..68f6ff9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mip-validator", - "version": "1.5.12", + "version": "1.5.13", "description": "MIP validator", "main": "index.js", "dependencies": { diff --git a/src/encoding/index.js b/src/encoding/index.js index 93d4878..f97b203 100644 --- a/src/encoding/index.js +++ b/src/encoding/index.js @@ -1,4 +1,4 @@ -const jschardet = require('./fake-jschardet.js') +const jschardet = require('jschardet') const ERR = require('../error/dfn.json') const allowedEncoding = ['UTF-8', 'ascii'] const logger = require('../logger.js')('mip-validator:encoding') diff --git a/test/encoding.js b/test/encoding.js index 118811e..1c365f3 100644 --- a/test/encoding.js +++ b/test/encoding.js @@ -2,7 +2,9 @@ const chai = require('./chai.js') const expect = chai.expect const Validator = require('..') const asciiStr = 'hello' +const ERR = require('../src/error/dfn.json') const utf8Str = '\xc3\xa0\xc3\xad\xc3\xa0\xc3\xa7\xc3\xa3' +const big5Str = '\xa6\xb8\xb1\x60\xa5\xce\xb0\xea\xa6\x72\xbc\xd0\xb7\xc7\xa6\x72\xc5\xe9\xaa\xed' describe('encoding', function() { it('should accept ASCII', function() { @@ -15,4 +17,10 @@ describe('encoding', function() { var result = validator.validate(utf8Str) expect(result).to.have.lengthOf(0) }) + it('should reject Big5', function () { + var validator = Validator({}) + var result = validator.validate(big5Str) + expect(result).to.have.lengthOf(1) + expect(result[0].code).to.equal(ERR.DISALLOWED_ENCODING.code) + }) }) \ No newline at end of file