File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const camelCase = require("camelcase");
7
7
* @returns {string[] }
8
8
*/
9
9
const getCssModuleKeys = ( content ) => {
10
- const keyRegex = / " ( [ \w - ] + ) " : / g;
10
+ const keyRegex = / " ( [ ^ " \n ] + ) " : / g;
11
11
let match ;
12
12
const cssModuleKeys = [ ] ;
13
13
Original file line number Diff line number Diff line change @@ -60,4 +60,23 @@ describe("getCssModuleKeys", () => {
60
60
const actual = getCssModuleKeys ( content ) ;
61
61
expect ( actual ) . toEqual ( [ ] ) ;
62
62
} ) ;
63
+
64
+ it ( "CSS module with special class names" , ( ) => {
65
+ const content = `.locals = {
66
+ "øæå": "nordic",
67
+ "+~@": "special",
68
+ "f\\'o\\'o": "escaped",
69
+ };` ;
70
+ const actual = getCssModuleKeys ( content ) ;
71
+ expect ( actual ) . toEqual ( [ "øæå" , "+~@" , "f\\'o\\'o" ] ) ;
72
+ } ) ;
73
+
74
+ it ( "CSS module with newline in class names should be ignored" , ( ) => {
75
+ const content = `.locals = {
76
+ "line1
77
+ line2": "twolinesdoesnotmakesense"
78
+ };` ;
79
+ const actual = getCssModuleKeys ( content ) ;
80
+ expect ( actual ) . toEqual ( [ ] ) ;
81
+ } ) ;
63
82
} ) ;
You can’t perform that action at this time.
0 commit comments