Skip to content

Commit 1100b7e

Browse files
committedJun 3, 2017
Trim quote from import path
1 parent f3b7f93 commit 1100b7e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed
 

‎src/extractICSS.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const importPattern = /^:import\(("[^"]*"|'[^']*'|[\w-\.]+)\)$/;
1+
const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
22

33
const getDeclsObject = rule => {
44
const object = {};
@@ -16,7 +16,7 @@ const extractICSS = (css, removeRules = true) => {
1616
if (node.selector.slice(0, 7) === ":import") {
1717
const matches = importPattern.exec(node.selector);
1818
if (matches) {
19-
const path = matches[1];
19+
const path = matches[1].replace(/'|"/g, "");
2020
const aliases = Object.assign(
2121
icssImports[path] || {},
2222
getDeclsObject(node)

‎test/extractICSS.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test("extract :import statements with identifier", () => {
2121
test("extract :import statements with single quoted path", () => {
2222
expect(runExtract(`:import('./colors.css') {}`)).toEqual({
2323
icssImports: {
24-
"'./colors.css'": {}
24+
"./colors.css": {}
2525
},
2626
icssExports: {}
2727
});
@@ -30,18 +30,18 @@ test("extract :import statements with single quoted path", () => {
3030
test("extract :import statements with double quoted path", () => {
3131
expect(runExtract(':import("./colors.css") {}')).toEqual({
3232
icssImports: {
33-
'"./colors.css"': {}
33+
"./colors.css": {}
3434
},
3535
icssExports: {}
3636
});
3737
});
3838

39-
test("extract :import with values", () => {
39+
test("not extract :import with values", () => {
4040
expect(
41-
runExtract(":import(colors) { i__blue: blue; i__red: red; }")
41+
runExtract(":import(./colors.css) { i__blue: blue; i__red: red; }")
4242
).toEqual({
4343
icssImports: {
44-
colors: {
44+
"./colors.css": {
4545
i__blue: "blue",
4646
i__red: "red"
4747
}
@@ -51,7 +51,7 @@ test("extract :import with values", () => {
5151
});
5252

5353
test("not extract invalid :import", () => {
54-
expect(runExtract(":import(./color.css) {}")).toEqual({
54+
expect(runExtract(":import(\\'./colors.css) {}")).toEqual({
5555
icssImports: {},
5656
icssExports: {}
5757
});

0 commit comments

Comments
 (0)
Please sign in to comment.