File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 11import assertString from './util/assertString' ;
22
3- let charsetRegex = / ^ [ ^ \s - _ ] (? ! .* ? [ - _ ] { 2 , } ) [ a - z 0 - 9 - \\ ] [ ^ \s ] * [ ^ - _ \s ] $ / ;
3+ const charsetRegex = / ^ [ a - z 0 - 9 ] (? ! .* [ - _ ] { 2 , } ) (?: [ a - z 0 - 9 _ - ] * [ a - z 0 - 9 ] ) ? $ / ;
44
55export default function isSlug ( str ) {
66 assertString ( str ) ;
Original file line number Diff line number Diff line change @@ -14211,13 +14211,15 @@ describe('Validators', () => {
1421114211 test ( {
1421214212 validator : 'isSlug' ,
1421314213 valid : [
14214+ 'f' ,
14215+ 'fo' ,
1421414216 'foo' ,
1421514217 'foo-bar' ,
1421614218 'foo_bar' ,
1421714219 'foo-bar-foo' ,
1421814220 'foo-bar_foo' ,
14219- 'foo-bar_foo* 75-b4r-**_foo ' ,
14220- 'foo-bar_foo*75-b4r-**_foo-&& ' ,
14221+ 'foo-75-b4r-foo ' ,
14222+ 'a1-b2_c3 ' ,
1422114223 ] ,
1422214224 invalid : [
1422314225 'not-----------slug' ,
@@ -14227,6 +14229,12 @@ describe('Validators', () => {
1422714229 '_not-slug' ,
1422814230 'not-slug_' ,
1422914231 'not slug' ,
14232+ 'i.am.not.a.slug' ,
14233+ 'slug.is.cool' ,
14234+ 'foo-bar_foo*75-b4r-**_foo' ,
14235+ 'foo-bar_foo*75-b4r-**_foo-&&' ,
14236+ 'Foo-Bar' ,
14237+ 'a:b' ,
1423014238 ] ,
1423114239 } ) ;
1423214240 } ) ;
You can’t perform that action at this time.
0 commit comments