File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,33 @@ var fs = require('fs'),
6
6
auth = require ( 'basic-auth' ) ,
7
7
httpProxy = require ( 'http-proxy' ) ,
8
8
corser = require ( 'corser' ) ,
9
+ path = require ( 'path' ) ,
9
10
secureCompare = require ( 'secure-compare' ) ;
10
11
12
+ // a hacky and direct workaround to fix https://github.com/http-party/http-server/issues/525
13
+ function getCaller ( ) {
14
+ try {
15
+ var stack = new Error ( ) . stack ;
16
+ var stackLines = stack . split ( '\n' ) ;
17
+ var callerStack = stackLines [ 3 ] ;
18
+ return callerStack . match ( / a t ( .+ ) \( / ) [ 1 ] ;
19
+ }
20
+ catch ( error ) {
21
+ return '' ;
22
+ }
23
+ }
24
+
25
+ var _pathNormalize = path . normalize ;
26
+ path . normalize = function ( p ) {
27
+ var caller = getCaller ( ) ;
28
+ var result = _pathNormalize ( p ) ;
29
+ // https://github.com/jfhbrook/node-ecstatic/blob/master/lib/ecstatic.js#L20
30
+ if ( caller === 'decodePathname' ) {
31
+ result = result . replace ( / \\ / g, '/' ) ;
32
+ }
33
+ return result ;
34
+ } ;
35
+
11
36
//
12
37
// Remark: backwards compatibility for previous
13
38
// case convention of HTTP
You can’t perform that action at this time.
0 commit comments