File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 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 \( ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ " ' ] + ) \) $ / ;
22
33const 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 )
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ test("extract :import statements with identifier", () => {
2121test ( "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", () => {
3030test ( "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
5353test ( "not extract invalid :import" , ( ) => {
54- expect ( runExtract ( ":import(./color .css) {}" ) ) . toEqual ( {
54+ expect ( runExtract ( ":import(\\'./colors .css) {}" ) ) . toEqual ( {
5555 icssImports : { } ,
5656 icssExports : { }
5757 } ) ;
You can’t perform that action at this time.
0 commit comments