From 9d66a77b4d15072680fdbd2ac80d55111cd75f35 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 1 Nov 2023 14:19:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0hostname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 ++ package.json | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 965778a..f4f16e8 100644 --- a/index.js +++ b/index.js @@ -51,6 +51,7 @@ export default class Request { url = '' host = '127.0.0.1' + hostname = '127.0.0.1' protocol = 'http' constructor(req, res, opts = {}) { @@ -60,6 +61,7 @@ export default class Request { this.#res = res this.host = req.headers['host'] || '127.0.0.1' + this.hostname = this.host.split(':')[0] this.protocol = req.headers['x-forwarded-proto'] || 'http' this.#cookies = parseCookie(this.headers['cookie'] || '') diff --git a/package.json b/package.json index 994ad0e..c1151b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gm5/request", - "version": "2.0.3", + "version": "2.0.4", "description": "对Http的Request进一步封装, 提供常用的API", "main": "index.js", "author": "yutent", @@ -15,8 +15,8 @@ "http" ], "dependencies": { - "es.shim": "^2.0.1", - "iofs": "^1.5.0" + "es.shim": "^2.2.0", + "iofs": "^1.5.3" }, "repository": "https://git.wkit.fun/gm5/request.git", "license": "MIT"