1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

feat: prioritize DENO_SERVE_ADDRESS over Deno.serve options (#6)

This commit is contained in:
Heyang Zhou 2024-08-09 02:18:21 +08:00 committed by GitHub
parent f14ae37686
commit 9e2fac050f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}