File tree Expand file tree Collapse file tree 3 files changed +5
-12
lines changed Expand file tree Collapse file tree 3 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -26,14 +26,15 @@ module.exports = function(content) {
26
26
else
27
27
throw new Error ( "Invalid value to query parameter attrs" ) ;
28
28
}
29
+ var root = query . root ;
29
30
var links = attrParse ( content , function ( tag , attr ) {
30
31
return attributes . indexOf ( tag + ":" + attr ) >= 0 ;
31
32
} ) ;
32
33
links . reverse ( ) ;
33
34
var data = { } ;
34
35
content = [ content ] ;
35
36
links . forEach ( function ( link ) {
36
- if ( / ^ d a t a : | ^ ( h t t p s ? : ) ? \/ \/ | ^ [ \{ \} \[ \] # * ; , ' § \$ % & \( = ? ` ´ \^ ° < > ] / . test ( link . value ) ) return ;
37
+ if ( ! loaderUtils . isUrlRequest ( link . value , root ) ) return ;
37
38
do {
38
39
var ident = randomIdent ( ) ;
39
40
} while ( data [ ident ] ) ;
@@ -59,14 +60,6 @@ module.exports = function(content) {
59
60
}
60
61
return "module.exports = " + JSON . stringify ( content ) . replace ( / x x x H T M L L I N K x x x [ 0 - 9 \. ] + x x x / g, function ( match ) {
61
62
if ( ! data [ match ] ) return match ;
62
- return '" + require(' + JSON . stringify ( urlToRequire ( data [ match ] ) ) + ') + "' ;
63
+ return '" + require(' + JSON . stringify ( loaderUtils . urlToRequest ( data [ match ] , root ) ) + ') + "' ;
63
64
} ) + ";" ;
64
65
}
65
-
66
- function urlToRequire ( url ) {
67
- if ( / ^ ~ / . test ( url ) )
68
- return url . substring ( 1 ) ;
69
- else
70
- return "./" + url ;
71
- }
72
-
Original file line number Diff line number Diff line change 6
6
"dependencies" : {
7
7
"html-minifier" : " 0.5.x" ,
8
8
"source-map" : " 0.1.x" ,
9
- "loader-utils" : " 0.2.x "
9
+ "loader-utils" : " ~ 0.2.2 "
10
10
},
11
11
"devDependencies" : {
12
12
"mocha" : " 1.17.x" ,
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ describe("loader", function() {
48
48
} ) ;
49
49
it ( "should accept root from query" , function ( ) {
50
50
loader . call ( {
51
- query : "?root=/test/ "
51
+ query : "?root=/test"
52
52
} , 'Text <img src="/image.png">' ) . should . be . eql (
53
53
'module.exports = "Text <img src=\\"" + require("/test/image.png") + "\\">";'
54
54
) ;
You can’t perform that action at this time.
0 commit comments