Skip to content

Commit b476b8d

Browse files
committed
Change class name regex to include all valid characters in CSS selectors
1 parent c331674 commit b476b8d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const camelCase = require("camelcase");
77
* @returns {string[]}
88
*/
99
const getCssModuleKeys = (content) => {
10-
const keyRegex = /"([\w-]+)":/g;
10+
const keyRegex = /"([^:")][^")]*)":/g;
1111
let match;
1212
const cssModuleKeys = [];
1313

test/utils.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ describe("getCssModuleKeys", () => {
6060
const actual = getCssModuleKeys(content);
6161
expect(actual).toEqual([]);
6262
});
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+
});
6373
});

0 commit comments

Comments
 (0)