Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/;
let charsetRegex = /^[a-z0-9](?!.*[-_]{2,})(?:[a-z0-9_-]*[a-z0-9])?$/;
Comment thread
Shrawak marked this conversation as resolved.
Outdated

export default function isSlug(str) {
assertString(str);
Expand Down
12 changes: 10 additions & 2 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14187,13 +14187,15 @@ describe('Validators', () => {
test({
validator: 'isSlug',
valid: [
'f',
'fo',
'foo',
'foo-bar',
Comment thread
Shrawak marked this conversation as resolved.
'foo_bar',
'foo-bar-foo',
'foo-bar_foo',
'foo-bar_foo*75-b4r-**_foo',
'foo-bar_foo*75-b4r-**_foo-&&',
'foo-75-b4r-foo',
'a1-b2_c3',
],
invalid: [
'not-----------slug',
Expand All @@ -14203,6 +14205,12 @@ describe('Validators', () => {
'_not-slug',
'not-slug_',
'not slug',
'i.am.not.a.slug',
'slug.is.cool',
'foo-bar_foo*75-b4r-**_foo',
'foo-bar_foo*75-b4r-**_foo-&&',
'Foo-Bar',
Comment thread
Shrawak marked this conversation as resolved.
'a:b',
],
});
});
Expand Down
Loading