From f2b71225498015f622ab0681265b19df91d62a01 Mon Sep 17 00:00:00 2001 From: Teppei SATO Date: Sat, 22 Apr 2017 20:31:51 +0900 Subject: [PATCH] fix: `url` format should not allow ftp (#6) add `http-url` format --- index.js | 1 + manifest-schema.json | 6 +++--- test/index.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 852a18f..3ce958f 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,7 @@ module.exports = function(json, options) { unknownFormats: true, errorDataPath: 'property', formats: { + 'http-url': str => validateUrl(str, true), 'https-url': str => validateUrl(str), 'relative-path': relativePath, }, diff --git a/manifest-schema.json b/manifest-schema.json index 40f2568..4a72f8c 100644 --- a/manifest-schema.json +++ b/manifest-schema.json @@ -74,17 +74,17 @@ "ja": { "type": "string", "minLength": 1, - "format": "url" + "format": "http-url" }, "en": { "type": "string", "minLength": 1, - "format": "url" + "format": "http-url" }, "zh": { "type": "string", "minLength": 1, - "format": "url" + "format": "http-url" } } }, diff --git a/test/index.js b/test/index.js index beabb82..e27fe9b 100644 --- a/test/index.js +++ b/test/index.js @@ -102,11 +102,11 @@ describe('validator', () => { assert(actual.errors.length === 2); }); - it('relative path is invalid for `url`', () => { + it('relative path is invalid for `http-url`', () => { const actual = validator(json({homepage_url: {en: 'foo/bar.html'}})); assert(actual.valid === false); assert(actual.errors.length === 1); - assert(actual.errors[0].params.format === 'url'); + assert(actual.errors[0].params.format === 'http-url'); }); it('"http:" is invalid for `https-url`', () => {