Skip to content

Commit ccac8fd

Browse files
authored
fix(isSlug): fix to disallow spaces (#1338)
* Fix: Space Error in isSlug() * Added Space Test for isSlug()
1 parent e501b9c commit ccac8fd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/lib/isSlug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assertString from './util/assertString';
22

3-
let charsetRegex = /^[^-_](?!.*?[-_]{2,})([a-z0-9\\-]{1,}).*[^-_]$/;
3+
let charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/;
44

55
export default function isSlug(str) {
66
assertString(str);

test/validators.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8369,6 +8369,7 @@ describe('Validators', () => {
83698369
'not-slug-',
83708370
'_not-slug',
83718371
'not-slug_',
8372+
'not slug',
83728373
],
83738374
});
83748375
});

0 commit comments

Comments
 (0)