From 9e2fac050fa30cc17c9143c5678a27330a7e644d Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Fri, 9 Aug 2024 02:18:21 +0800 Subject: [PATCH] feat: prioritize DENO_SERVE_ADDRESS over Deno.serve options (#6) --- ext/http/00_serve.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ext/http/00_serve.ts b/ext/http/00_serve.ts index 23a97cb604..eb1c74a99c 100644 --- a/ext/http/00_serve.ts +++ b/ext/http/00_serve.ts @@ -185,7 +185,7 @@ class InnerRequest { this.headerList; this.close(); - this.#upgraded = () => {}; + this.#upgraded = () => { }; const upgradeRid = op_http_upgrade_raw(external); @@ -582,15 +582,15 @@ function serve(arg1, arg2) { options = { __proto__: null }; } - const canOverrideOptions = !ObjectHasOwn(options, "path") && - !ObjectHasOwn(options, "hostname") && - !ObjectHasOwn(options, "port"); + // const canOverrideOptions = !ObjectHasOwn(options, "path") && + // !ObjectHasOwn(options, "hostname") && + // !ObjectHasOwn(options, "port"); const env = Deno.permissions.querySync({ name: "env", variable: "DENO_SERVE_ADDRESS" }) - .state === "granted" && + .state === "granted" && Deno.env.get("DENO_SERVE_ADDRESS"); - if (canOverrideOptions && env) { + if (env) { const delim = env.indexOf("/"); if (delim >= 0) { const network = env.slice(0, delim); @@ -614,9 +614,12 @@ function serve(arg1, arg2) { } options.hostname = hostname; options.port = port; + delete options.path; break; } case "unix": { + delete options.hostname; + delete options.port; options.path = address; break; }