image: fix absolute path & reset to 'default' instead of 'value' when receiving an empty value
This commit is contained in:
parent
c85c2ad2c4
commit
88a3d8da2a
2 changed files with 5 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
var urlparser = require('url'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
send = require('send'),
|
||||
http = require('http'),
|
||||
server = http.createServer(httpRoute),
|
||||
|
|
@ -16,7 +17,9 @@ var urlparser = require('url'),
|
|||
function httpRoute(req, res) {
|
||||
|
||||
res.sendFile = (path)=>{
|
||||
send(req, path.split('?')[0]).pipe(res)
|
||||
var fpath = path.split('?')[0]
|
||||
if (!fs.existsSync(fpath)) throw `File "${fpath}" not found.`
|
||||
send(req, fpath).pipe(res)
|
||||
}
|
||||
|
||||
var url = req.url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue