patch index.html
parent
e2db34a6b2
commit
45e2f4c9d9
5
index.js
5
index.js
|
@ -68,9 +68,7 @@ function createServer() {
|
||||||
std.out(`尝试使用${port}端口...`)
|
std.out(`尝试使用${port}端口...`)
|
||||||
http
|
http
|
||||||
.createServer(function (req, res) {
|
.createServer(function (req, res) {
|
||||||
let pathname = parse(req.url)
|
let pathname = parse(req.url).pathname.slice(1)
|
||||||
.pathname.slice(1)
|
|
||||||
.replace(/[\/]+$/, '')
|
|
||||||
|
|
||||||
pathname = decode(pathname) || 'index.html'
|
pathname = decode(pathname) || 'index.html'
|
||||||
|
|
||||||
|
@ -95,6 +93,7 @@ function createServer() {
|
||||||
} else {
|
} else {
|
||||||
res.setHeader('content-type', MIME_TYPES.html)
|
res.setHeader('content-type', MIME_TYPES.html)
|
||||||
res.setHeader('content-length', 0)
|
res.setHeader('content-length', 0)
|
||||||
|
res.setHeader('x-url', file)
|
||||||
res.writeHead(404, 'Not Found')
|
res.writeHead(404, 'Not Found')
|
||||||
res.end('')
|
res.end('')
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "simple-http",
|
"name": "simple-http",
|
||||||
"displayName": "simple http",
|
"displayName": "simple http",
|
||||||
"description": "🔥 简单的http服务器, 方便临时调试html",
|
"description": "🔥 简单的http服务器, 方便临时调试html",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"publisher": "yutent",
|
"publisher": "yutent",
|
||||||
"author": "Yutent [@yutent]",
|
"author": "Yutent [@yutent]",
|
||||||
"icon": "logo.png",
|
"icon": "logo.png",
|
||||||
|
|
Loading…
Reference in New Issue