0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Add underscores to general validation

fixes #5816

- general slugs and other fields should permit underscores as well as dashes
This commit is contained in:
Hannah Wolfe 2015-09-04 18:29:15 +01:00
parent 7b3d60b727
commit 95623e60ae
2 changed files with 4 additions and 4 deletions

View file

@ -126,7 +126,7 @@ utils = {
errors = errors.concat(validation.validate(value, key, globalValidations[key]));
} else {
// all other keys should be an alphanumeric string + -, like slug, tag, author, status, etc
errors = errors.concat(validation.validate(value, key, {matches: /^[a-z0-9\-]+$/}));
errors = errors.concat(validation.validate(value, key, {matches: /^[a-z0-9\-_]+$/}));
}
}
});

View file

@ -217,9 +217,9 @@ describe('API Utils', function () {
check('limit', valid, invalid);
});
it('can validate `slug` or `status` or `author` etc as a-z, 0-9 and -', function () {
valid = ['hello-world', 'hello', '1-2-3', 1, '-1', -1];
invalid = ['hello_world', '!things', '?other-things', 'thing"', '`ticks`'];
it('can validate `slug` or `status` or `author` etc as a-z, 0-9, - and _', function () {
valid = ['hello-world', 'hello', '1-2-3', 1, '-1', -1, 'hello_world'];
invalid = ['hello~world', '!things', '?other-things', 'thing"', '`ticks`'];
check('slug', valid, invalid);
check('status', valid, invalid);