diff --git a/index.js b/index.js index 8c14966..c3d0a5b 100644 --- a/index.js +++ b/index.js @@ -68,9 +68,7 @@ function createServer() { std.out(`尝试使用${port}端口...`) http .createServer(function (req, res) { - let pathname = parse(req.url) - .pathname.slice(1) - .replace(/[\/]+$/, '') + let pathname = parse(req.url).pathname.slice(1) pathname = decode(pathname) || 'index.html' @@ -95,6 +93,7 @@ function createServer() { } else { res.setHeader('content-type', MIME_TYPES.html) res.setHeader('content-length', 0) + res.setHeader('x-url', file) res.writeHead(404, 'Not Found') res.end('') } diff --git a/package.json b/package.json index a9dfc41..8f6c4ef 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "simple-http", "displayName": "simple http", "description": "🔥 简单的http服务器, 方便临时调试html", - "version": "1.2.2", + "version": "1.2.3", "publisher": "yutent", "author": "Yutent [@yutent]", "icon": "logo.png",