File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ var htmlMinifier = require("html-minifier");
6
6
var attrParse = require ( "./lib/attributesParser" ) ;
7
7
var SourceNode = require ( "source-map" ) . SourceNode ;
8
8
var loaderUtils = require ( "loader-utils" ) ;
9
+ var url = require ( "url" ) ;
9
10
10
11
function randomIdent ( ) {
11
12
return "xxxHTMLLINKxxx" + Math . random ( ) + Math . random ( ) + "xxx" ;
@@ -35,6 +36,15 @@ module.exports = function(content) {
35
36
content = [ content ] ;
36
37
links . forEach ( function ( link ) {
37
38
if ( ! loaderUtils . isUrlRequest ( link . value , root ) ) return ;
39
+
40
+ var uri = url . parse ( link . value ) ;
41
+ if ( uri . hash !== null && uri . hash !== undefined ) {
42
+ uri . hash = null ;
43
+ link . value = uri . format ( ) ;
44
+ link . length = link . value . length ;
45
+ }
46
+
47
+
38
48
do {
39
49
var ident = randomIdent ( ) ;
40
50
} while ( data [ ident ] ) ;
Original file line number Diff line number Diff line change @@ -53,4 +53,9 @@ describe("loader", function() {
53
53
'module.exports = "Text <img src=\\"" + require("/test/image.png") + "\\">";'
54
54
) ;
55
55
} ) ;
56
+ it ( "should ignore hash fragments in URLs" , function ( ) {
57
+ loader . call ( { } , '<img src="icons.svg#hash">' ) . should . be . eql (
58
+ 'module.exports = "<img src=\\"" + require("./icons.svg") + "#hash\\">";'
59
+ ) ;
60
+ } ) ;
56
61
} ) ;
You can’t perform that action at this time.
0 commit comments