File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
- const importPattern = / ^ : i m p o r t \( ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ \w - \. ] + ) \) $ / ;
1
+ const importPattern = / ^ : i m p o r t \( ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ " ' ] + ) \) $ / ;
2
2
3
3
const getDeclsObject = rule => {
4
4
const object = { } ;
@@ -16,7 +16,7 @@ const extractICSS = (css, removeRules = true) => {
16
16
if ( node . selector . slice ( 0 , 7 ) === ":import" ) {
17
17
const matches = importPattern . exec ( node . selector ) ;
18
18
if ( matches ) {
19
- const path = matches [ 1 ] ;
19
+ const path = matches [ 1 ] . replace ( / ' | " / g , "" ) ;
20
20
const aliases = Object . assign (
21
21
icssImports [ path ] || { } ,
22
22
getDeclsObject ( node )
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ test("extract :import statements with identifier", () => {
21
21
test ( "extract :import statements with single quoted path" , ( ) => {
22
22
expect ( runExtract ( `:import('./colors.css') {}` ) ) . toEqual ( {
23
23
icssImports : {
24
- "' ./colors.css' " : { }
24
+ "./colors.css" : { }
25
25
} ,
26
26
icssExports : { }
27
27
} ) ;
@@ -30,18 +30,18 @@ test("extract :import statements with single quoted path", () => {
30
30
test ( "extract :import statements with double quoted path" , ( ) => {
31
31
expect ( runExtract ( ':import("./colors.css") {}' ) ) . toEqual ( {
32
32
icssImports : {
33
- ' "./colors.css"' : { }
33
+ "./colors.css" : { }
34
34
} ,
35
35
icssExports : { }
36
36
} ) ;
37
37
} ) ;
38
38
39
- test ( "extract :import with values" , ( ) => {
39
+ test ( "not extract :import with values" , ( ) => {
40
40
expect (
41
- runExtract ( ":import(colors) { i__blue: blue; i__red: red; }" )
41
+ runExtract ( ":import(./ colors.css ) { i__blue: blue; i__red: red; }" )
42
42
) . toEqual ( {
43
43
icssImports : {
44
- colors : {
44
+ "./ colors.css" : {
45
45
i__blue : "blue" ,
46
46
i__red : "red"
47
47
}
@@ -51,7 +51,7 @@ test("extract :import with values", () => {
51
51
} ) ;
52
52
53
53
test ( "not extract invalid :import" , ( ) => {
54
- expect ( runExtract ( ":import(./color .css) {}" ) ) . toEqual ( {
54
+ expect ( runExtract ( ":import(\\'./colors .css) {}" ) ) . toEqual ( {
55
55
icssImports : { } ,
56
56
icssExports : { }
57
57
} ) ;
You can’t perform that action at this time.
0 commit comments