Skip to content

Commit

Permalink
Trim quote from import path
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Jun 3, 2017
1 parent f3b7f93 commit 1100b7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/extractICSS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const importPattern = /^:import\(("[^"]*"|'[^']*'|[\w-\.]+)\)$/;
const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;

const getDeclsObject = rule => {
const object = {};
Expand All @@ -16,7 +16,7 @@ const extractICSS = (css, removeRules = true) => {
if (node.selector.slice(0, 7) === ":import") {
const matches = importPattern.exec(node.selector);
if (matches) {
const path = matches[1];
const path = matches[1].replace(/'|"/g, "");
const aliases = Object.assign(
icssImports[path] || {},
getDeclsObject(node)
Expand Down
12 changes: 6 additions & 6 deletions test/extractICSS.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test("extract :import statements with identifier", () => {
test("extract :import statements with single quoted path", () => {
expect(runExtract(`:import('./colors.css') {}`)).toEqual({
icssImports: {
"'./colors.css'": {}
"./colors.css": {}
},
icssExports: {}
});
Expand All @@ -30,18 +30,18 @@ test("extract :import statements with single quoted path", () => {
test("extract :import statements with double quoted path", () => {
expect(runExtract(':import("./colors.css") {}')).toEqual({
icssImports: {
'"./colors.css"': {}
"./colors.css": {}
},
icssExports: {}
});
});

test("extract :import with values", () => {
test("not extract :import with values", () => {
expect(
runExtract(":import(colors) { i__blue: blue; i__red: red; }")
runExtract(":import(./colors.css) { i__blue: blue; i__red: red; }")
).toEqual({
icssImports: {
colors: {
"./colors.css": {
i__blue: "blue",
i__red: "red"
}
Expand All @@ -51,7 +51,7 @@ test("extract :import with values", () => {
});

test("not extract invalid :import", () => {
expect(runExtract(":import(./color.css) {}")).toEqual({
expect(runExtract(":import(\\'./colors.css) {}")).toEqual({
icssImports: {},
icssExports: {}
});
Expand Down

0 comments on commit 1100b7e

Please sign in to comment.