File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ test('invalid characters', (t) => {
3434 t . regex ( invalidChars ( "dingo'sky" ) , / I n v a l i d / )
3535 t . regex ( invalidChars ( 'dingo\\sky' ) , / I n v a l i d / )
3636 t . regex ( invalidChars ( 'dingo`sky' ) , / I n v a l i d / )
37- t . regex ( invalidChars ( 'dingo\x7Fsky ' ) , / I n v a l i d / )
37+ t . regex ( invalidChars ( 'dingo\u0088sky ' ) , / I n v a l i d / )
3838} )
3939
4040test ( 'non-unique character' , ( t ) => t . regex ( invalidChars ( 'unique' ) , / n o t u n i q u e / ) )
Original file line number Diff line number Diff line change 1- import { ValidChars } from " ../types/puid"
1+ import { ValidChars } from ' ../types/puid'
22
33/**
44 * Pre-defined character sets
@@ -42,16 +42,17 @@ export const charsName = (chars: string): string => {
4242}
4343
4444const validChar = ( char : string ) : boolean => {
45- const codePoint = codePointOf ( char )
45+ const codePointNonBreakSpace = 160
4646
47- if ( 160 < codePoint ) return true
47+ const codePoint = codePointOf ( char )
4848
49- if ( char == '!' ) return true
50- if ( codePoint < codePointOf ( '#' ) ) return false
49+ if ( codePoint < codePointOf ( '!' ) ) return false
50+ if ( char == '"' ) return false
5151 if ( char == "'" ) return false
5252 if ( char == '\\' ) return false
5353 if ( char == '`' ) return false
54- if ( codePointOf ( '~' ) < codePoint ) return false
54+ if ( codePoint <= codePointOf ( '~' ) ) return true
55+ if ( codePoint < codePointNonBreakSpace ) return false
5556
5657 return true
5758}
You can’t perform that action at this time.
0 commit comments