Skip to content

Commit

Permalink
fix(isSlug): fix to disallow spaces (#1338)
Browse files Browse the repository at this point in the history
* Fix: Space Error in isSlug()

* Added Space Test for isSlug()
  • Loading branch information
asp2809 authored May 31, 2020
1 parent e501b9c commit ccac8fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isSlug.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -8369,6 +8369,7 @@ describe('Validators', () => {
'not-slug-',
'_not-slug',
'not-slug_',
'not slug',
],
});
});
Expand Down

0 comments on commit ccac8fd

Please sign in to comment.