windows: escape drive colon to avoid unknown protocol error and escape antislashes (#515)
This commit is contained in:
parent
4196bfb32d
commit
02ec4f80a5
6 changed files with 48 additions and 11 deletions
|
|
@ -32,7 +32,13 @@ function httpRoute(req, res) {
|
|||
} else if (/^\/(assets|client)\//.test(req.url)){
|
||||
res.sendFile(path.resolve(__dirname + '/..' + req.url))
|
||||
} else {
|
||||
res.sendFile(path.resolve(req.url))
|
||||
var url = req.url
|
||||
|
||||
// windows absolute path fix
|
||||
url = url.replace('_:_', ':') // escaped drive colon
|
||||
url = url.replace(/^\/([^/]*):/, '$1') // strip leading slash
|
||||
|
||||
res.sendFile(path.resolve(url))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue