Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
fix: url format should not allow ftp (#6)
Browse files Browse the repository at this point in the history
add `http-url` format
  • Loading branch information
teppeis committed Apr 22, 2017
1 parent 22f9864 commit f2b7122
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -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,
},
Expand Down
6 changes: 3 additions & 3 deletions manifest-schema.json
Expand Up @@ -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"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Expand Up @@ -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`', () => {
Expand Down

0 comments on commit f2b7122

Please sign in to comment.