@@ -2,7 +2,7 @@ var should = require("should");
2
2
var getFilenameFromUrl = require ( "../lib/GetFilenameFromUrl" ) ;
3
3
4
4
function testUrl ( options ) {
5
- var url = getFilenameFromUrl ( options . publicPath , options . outputPath , options . url ) ;
5
+ var url = getFilenameFromUrl ( options . publicPath , options , options . url ) ;
6
6
should . strictEqual ( url , options . expected ) ;
7
7
}
8
8
@@ -33,47 +33,47 @@ describe("GetFilenameFromUrl", function() {
33
33
url : "/test.html?foo=bar" ,
34
34
outputPath : "/" ,
35
35
publicPath : "/" ,
36
- expected : "/test.html" ,
36
+ expected : "/test.html"
37
37
} , {
38
38
url : "/a.js" ,
39
39
outputPath : "/dist" ,
40
40
publicPath : "/" ,
41
- expected : "/dist/a.js" ,
41
+ expected : "/dist/a.js"
42
42
} , {
43
43
url : "/b.js" ,
44
44
outputPath : "/" ,
45
45
publicPath : undefined ,
46
- expected : "/b.js" ,
46
+ expected : "/b.js"
47
47
} , {
48
48
url : "/c.js" ,
49
49
outputPath : undefined ,
50
50
publicPath : undefined ,
51
- expected : "/c.js" ,
51
+ expected : "/c.js"
52
52
} , {
53
53
url : "/more/complex/path.js" ,
54
54
outputPath : "/a" ,
55
55
publicPath : "/" ,
56
- expected : "/a/more/complex/path.js" ,
56
+ expected : "/a/more/complex/path.js"
57
57
} , {
58
58
url : "/more/complex/path.js" ,
59
59
outputPath : "/a" ,
60
60
publicPath : "/complex" ,
61
- expected : false ,
61
+ expected : false
62
62
} , {
63
63
url : "c.js" ,
64
64
outputPath : "/dist" ,
65
65
publicPath : "/" ,
66
- expected : false , // publicPath is not in url, so it should fail
66
+ expected : false // publicPath is not in url, so it should fail
67
67
} , {
68
68
url : "/bar/" ,
69
69
outputPath : "/foo" ,
70
70
publicPath : "/bar/" ,
71
- expected : "/foo" ,
71
+ expected : "/foo"
72
72
} , {
73
73
url : "/bar/" ,
74
74
outputPath : "/" ,
75
75
publicPath : "http://localhost/foo/" ,
76
- expected : false ,
76
+ expected : false
77
77
} , {
78
78
url : "http://test.domain/test/sample.js" ,
79
79
outputPath : "/" ,
@@ -94,7 +94,70 @@ describe("GetFilenameFromUrl", function() {
94
94
outputPath : "/" ,
95
95
publicPath : "/" ,
96
96
expected : "/pathname with spaces.js"
97
- } ,
97
+ } , {
98
+ url : "/js/sample.js" ,
99
+ compilers : [
100
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
101
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
102
+ ] ,
103
+ outputPath : "/root" ,
104
+ publicPath : "/" ,
105
+ expected : "/foo/sample.js"
106
+ } , {
107
+ url : "/css/sample.css" ,
108
+ compilers : [
109
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
110
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
111
+ ] ,
112
+ outputPath : "/root" ,
113
+ publicPath : "/" ,
114
+ expected : "/bar/sample.css"
115
+ } , {
116
+ url : "/other/sample.txt" ,
117
+ compilers : [
118
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
119
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
120
+ ] ,
121
+ outputPath : "/root" ,
122
+ publicPath : "/" ,
123
+ expected : "/root/other/sample.txt"
124
+ } , {
125
+ url : "/js/sample.js" ,
126
+ compilers : [
127
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
128
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
129
+ ] ,
130
+ outputPath : "/root" ,
131
+ publicPath : "/test/" ,
132
+ expected : "/foo/sample.js"
133
+ } , {
134
+ url : "/css/sample.css" ,
135
+ compilers : [
136
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
137
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
138
+ ] ,
139
+ outputPath : "/root" ,
140
+ publicPath : "/test/" ,
141
+ expected : "/bar/sample.css"
142
+ } , {
143
+ url : "/other/sample.txt" ,
144
+ compilers : [
145
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
146
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
147
+ ] ,
148
+ outputPath : "/root" ,
149
+ publicPath : "/test/" ,
150
+ expected : false
151
+ } , {
152
+ url : "/test/sample.txt" ,
153
+ compilers : [
154
+ { outputPath : "/foo" , options : { output : { publicPath : "/js/" } } } ,
155
+ { outputPath : "/bar" , options : { output : { publicPath : "/css/" } } }
156
+ ] ,
157
+ outputPath : "/root" ,
158
+ publicPath : "/test/" ,
159
+ expected : "/root/sample.txt"
160
+ }
98
161
] ;
99
162
results . forEach ( testUrl ) ;
100
163
} ) ;
0 commit comments