@@ -8,6 +8,8 @@ var loaderUtils = require("loader-utils");
88module . exports = function ( content ) {
99 this . cacheable && this . cacheable ( ) ;
1010 var result = [ ] ;
11+ var query = loaderUtils . parseQuery ( this . query ) ;
12+ var root = query . root ;
1113 var tree = csso . parse ( content , "stylesheet" ) ;
1214 if ( tree && this && this . minimize ) {
1315 tree = csso . compress ( tree ) ;
@@ -37,19 +39,19 @@ module.exports = function(content) {
3739 var uriRegExp = / % C S S U R L \[ % ( .* ?) % \] C S S U R L % / g;
3840 css = css . replace ( uriRegExp , function ( str ) {
3941 var match = / ^ % C S S U R L \[ % ( .* ?) % \] C S S U R L % $ / . exec ( str ) ;
40- if ( / ^ d a t a : | ^ ( h t t p s ? : ) ? \/ \/ / . test ( match [ 1 ] ) ) return match [ 1 ] ;
42+ if ( ! loaderUtils . isUrlRequest ( match [ 1 ] , root ) ) return match [ 1 ] ;
4143 var idx = match [ 1 ] . indexOf ( "?" ) ;
4244 if ( idx < 0 ) idx = match [ 1 ] . indexOf ( "#" ) ;
4345 if ( idx > 0 ) {
4446 // in cases like url('webfont.eot?#iefix')
4547 var url = JSON . parse ( "\"" + match [ 1 ] . substr ( 0 , idx ) + "\"" ) ;
46- return "\"+require(" + JSON . stringify ( urlToRequire ( url ) ) + ")+\"" + match [ 1 ] . substr ( idx ) ;
48+ return "\"+require(" + JSON . stringify ( loaderUtils . urlToRequest ( url , root ) ) + ")+\"" + match [ 1 ] . substr ( idx ) ;
4749 } else if ( idx === 0 ) {
4850 // only hash
4951 return match [ 1 ] ;
5052 }
5153 var url = JSON . parse ( "\"" + match [ 1 ] + "\"" ) ;
52- return "\"+require(" + JSON . stringify ( urlToRequire ( url ) ) + ")+\"" ;
54+ return "\"+require(" + JSON . stringify ( loaderUtils . urlToRequest ( url , root ) ) + ")+\"" ;
5355 } ) ;
5456 result . push ( css ) ;
5557 var cssRequest = loaderUtils . getRemainingRequest ( this ) ;
@@ -63,12 +65,6 @@ module.exports = function(content) {
6365 this . callback ( null , stringWithMap . code , stringWithMap . map . toJSON ( ) ) ;
6466}
6567
66- function urlToRequire ( url ) {
67- if ( / ^ ~ / . test ( url ) )
68- return url . substring ( 1 ) ;
69- else
70- return "./" + url ;
71- }
7268function extractImports ( tree ) {
7369 var results = [ ] ;
7470 var removes = [ ] ;
0 commit comments