File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ describe("useAutoId", () => {
81
81
82
82
cy . findByText ( "A paragraph" )
83
83
. invoke ( "attr" , "id" )
84
- . should ( "match" , / ^ f d z - p r e f i x - - : ? [ a - z 0 - 9 : ] + : ? $ / ) ;
84
+ . should ( "match" , / ^ f d z - p r e f i x - - [ a - z 0 - 9 ] + $ / ) ;
85
85
} ) ;
86
86
87
87
context ( "React <18 (no useId support)" , ( ) => {
@@ -123,18 +123,18 @@ describe("useAutoId", () => {
123
123
124
124
cy . findByText ( "A paragraph" )
125
125
. invoke ( "attr" , "id" )
126
- . should ( "match" , / ^ : ? [ a - z 0 - 9 : ] + : ? $ / ) ;
126
+ . should ( "match" , / ^ [ a - z 0 - 9 ] + $ / ) ;
127
127
cy . findByText ( "An inline span element" )
128
128
. invoke ( "attr" , "id" )
129
- . should ( "match" , / ^ : ? [ a - z 0 - 9 : ] + : ? $ / ) ;
129
+ . should ( "match" , / ^ [ a - z 0 - 9 ] + $ / ) ;
130
130
} ) ;
131
131
132
132
it ( "applies prefix to ID generated by React.useId" , ( ) => {
133
133
cy . mount ( < DemoComponent prefix = "fdz-js-prefix" /> ) ;
134
134
135
135
cy . findByText ( "A paragraph" )
136
136
. invoke ( "attr" , "id" )
137
- . should ( "match" , / ^ f d z - j s - p r e f i x - - : ? [ a - z 0 - 9 : ] + : ? $ / ) ;
137
+ . should ( "match" , / ^ f d z - j s - p r e f i x - - [ a - z 0 - 9 ] + $ / ) ;
138
138
} ) ;
139
139
140
140
it ( "uses static fallback ID when explicitly provided" , ( ) => {
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ export function useAutoId(
87
87
}
88
88
} ) ;
89
89
90
- const baseId = customId ?? reactId ?? generatedId ;
90
+ const baseId = customId ?? reactId ?. replace ( / : / g , "" ) ?? generatedId ;
91
91
92
92
return useMemo ( ( ) => {
93
93
return prefix ? makeId ( prefix , baseId ) : baseId ;
You can’t perform that action at this time.
0 commit comments