Skip to content

Commit fadbdc1

Browse files
authored
Merge pull request #49 from niklasmh/master
Support nordic characters in CSS class names
2 parents c331674 + d93ac47 commit fadbdc1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-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 = /"([^"\n]+)":/g;
1111
let match;
1212
const cssModuleKeys = [];
1313

test/utils.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,23 @@ 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+
});
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+
});
6382
});

0 commit comments

Comments
 (0)