diff --git a/src/lib/isSlug.js b/src/lib/isSlug.js index bb1b290bb..da0193137 100644 --- a/src/lib/isSlug.js +++ b/src/lib/isSlug.js @@ -1,6 +1,6 @@ import assertString from './util/assertString'; -let charsetRegex = /^[^-_](?!.*?[-_]{2,})([a-z0-9\\-]{1,}).*[^-_]$/; +let charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/; export default function isSlug(str) { assertString(str); diff --git a/test/validators.js b/test/validators.js index 0caf824fd..a842e71d9 100755 --- a/test/validators.js +++ b/test/validators.js @@ -8369,6 +8369,7 @@ describe('Validators', () => { 'not-slug-', '_not-slug', 'not-slug_', + 'not slug', ], }); });