File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @vanilla-extract/css ' : patch
3+ ---
4+
5+ Ensure whitespace is stripped from debug Ids
Original file line number Diff line number Diff line change 1+ import { setFileScope , endFileScope } from './fileScope' ;
2+ import { generateIdentifier } from './identifier' ;
3+
4+ describe ( 'identifier' , ( ) => {
5+ beforeAll ( ( ) => {
6+ setFileScope ( 'test' ) ;
7+ } ) ;
8+
9+ afterAll ( ( ) => {
10+ endFileScope ( ) ;
11+ } ) ;
12+
13+ it ( `should create a valid identifier` , ( ) => {
14+ expect ( generateIdentifier ( undefined ) ) . toMatchInlineSnapshot ( `"skkcyc0"` ) ;
15+ } ) ;
16+
17+ it ( 'should create a valid identifier with a debug id' , ( ) => {
18+ expect ( generateIdentifier ( 'debug' ) ) . toMatchInlineSnapshot (
19+ `"debug__skkcyc1"` ,
20+ ) ;
21+ } ) ;
22+
23+ it ( 'should create a valid identifier with a debug id with whitespace' , ( ) => {
24+ expect ( generateIdentifier ( 'debug and more' ) ) . toMatchInlineSnapshot (
25+ `"debug_and_more__skkcyc2"` ,
26+ ) ;
27+ } ) ;
28+ } ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { getIdentOption } from './adapter';
44import { getAndIncrementRefCounter , getFileScope } from './fileScope' ;
55
66function getDevPrefix ( debugId : string | undefined ) {
7- const parts = debugId ? [ debugId ] : [ ] ;
7+ const parts = debugId ? [ debugId . replace ( / \s / g , '_' ) ] : [ ] ;
88 const { filePath } = getFileScope ( ) ;
99
1010 const matches = filePath . match (
You can’t perform that action at this time.
0 commit comments