@@ -629,16 +629,79 @@ describe("runLoaders", function() {
629
629
} ) ;
630
630
} ) ;
631
631
}
632
+ it ( "should support escaping in resource" , function ( done ) {
633
+ runLoaders ( {
634
+ resource : path . resolve ( fixtures , "res\0#ource.bin" )
635
+ } , function ( err , result ) {
636
+ if ( err ) return done ( err ) ;
637
+ result . result . should . be . eql ( [ Buffer . from ( "resource" , "utf-8" ) ] ) ;
638
+ result . cacheable . should . be . eql ( true ) ;
639
+ result . fileDependencies . should . be . eql ( [
640
+ path . resolve ( fixtures , "res#ource.bin" )
641
+ ] ) ;
642
+ result . contextDependencies . should . be . eql ( [ ] ) ;
643
+ done ( ) ;
644
+ } ) ;
645
+ } ) ;
646
+ it ( "should have to correct keys in context when using escaping" , function ( done ) {
647
+ runLoaders ( {
648
+ resource : path . resolve ( fixtures , "res\0#ource.bin" ) + "?query\0#frag" ,
649
+ loaders : [
650
+ path . resolve ( fixtures , "keys-loader.js" ) + "?loader\0#query"
651
+ ]
652
+ } , function ( err , result ) {
653
+ if ( err ) return done ( err ) ;
654
+ try {
655
+ JSON . parse ( result . result [ 0 ] ) . should . be . eql ( {
656
+ context : fixtures ,
657
+ resource : path . resolve ( fixtures , "res\0#ource.bin" ) + "?query\0#frag" ,
658
+ resourcePath : path . resolve ( fixtures , "res#ource.bin" ) ,
659
+ resourceQuery : "?query#frag" ,
660
+ resourceFragment : "" ,
661
+ loaderIndex : 0 ,
662
+ query : "?loader#query" ,
663
+ currentRequest : path . resolve ( fixtures , "keys-loader.js" ) + "?loader\0#query!" +
664
+ path . resolve ( fixtures , "res\0#ource.bin" ) + "?query\0#frag" ,
665
+ remainingRequest : path . resolve ( fixtures , "res\0#ource.bin" ) + "?query\0#frag" ,
666
+ previousRequest : "" ,
667
+ request : path . resolve ( fixtures , "keys-loader.js" ) + "?loader\0#query!" +
668
+ path . resolve ( fixtures , "res\0#ource.bin" ) + "?query\0#frag" ,
669
+ data : null ,
670
+ loaders : [ {
671
+ request : path . resolve ( fixtures , "keys-loader.js" ) + "?loader\0#query" ,
672
+ path : path . resolve ( fixtures , "keys-loader.js" ) ,
673
+ query : "?loader#query" ,
674
+ fragment : "" ,
675
+ data : null ,
676
+ pitchExecuted : true ,
677
+ normalExecuted : true
678
+ } ]
679
+ } ) ;
680
+ } catch ( e ) {
681
+ return done ( e ) ;
682
+ }
683
+ done ( ) ;
684
+ } ) ;
685
+ } ) ;
686
+
632
687
describe ( "getContext" , function ( ) {
633
688
var TESTS = [
634
689
[ "/" , "/" ] ,
635
690
[ "/path/file.js" , "/path" ] ,
691
+ [ "/path/file.js#fragment" , "/path" ] ,
692
+ [ "/path/file.js?query" , "/path" ] ,
693
+ [ "/path/file.js?query#fragment" , "/path" ] ,
694
+ [ "/path/\0#/file.js" , "/path/#" ] ,
636
695
[ "/some/longer/path/file.js" , "/some/longer/path" ] ,
637
696
[ "/file.js" , "/" ] ,
638
697
[ "C:\\" , "C:\\" ] ,
639
698
[ "C:\\file.js" , "C:\\" ] ,
640
699
[ "C:\\some\\path\\file.js" , "C:\\some\\path" ] ,
641
700
[ "C:\\path\\file.js" , "C:\\path" ] ,
701
+ [ "C:\\path\\file.js#fragment" , "C:\\path" ] ,
702
+ [ "C:\\path\\file.js?query" , "C:\\path" ] ,
703
+ [ "C:\\path\\file.js?query#fragment" , "C:\\path" ] ,
704
+ [ "C:\\path\\\0#\\file.js" , "C:\\path\\#" ] ,
642
705
] ;
643
706
TESTS . forEach ( function ( testCase ) {
644
707
it ( "should get the context of '" + testCase [ 0 ] + "'" , function ( ) {
0 commit comments