summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-10-29 00:41:02 +0000
committerGitHub <noreply@github.com>2024-10-29 00:41:02 +0000
commit46e5ed1a642edcd998d1e22c9b37e0c4aa298e1e (patch)
tree7c79324027a675ec847d4676743b129aa3cf7770 /ext
parent484f8ca9c30909914eb3348b2df10d44e2753248 (diff)
Revert "fix(ext/node): use primordials in `ext/node/polyfills/https.ts` (#26323)" (#26613)
…s` (#26323)" This reverts commit afb33b3c2597c9ec943f71218b236486fbc86e23. Reverting because it caused a regression - https://github.com/denoland/deno/issues/26612. Closes https://github.com/denoland/deno/issues/26612.
Diffstat (limited to 'ext')
-rw-r--r--ext/node/polyfills/https.ts31
1 files changed, 12 insertions, 19 deletions
diff --git a/ext/node/polyfills/https.ts b/ext/node/polyfills/https.ts
index dd24cf048..f60c5e471 100644
--- a/ext/node/polyfills/https.ts
+++ b/ext/node/polyfills/https.ts
@@ -1,6 +1,9 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// TODO(petamoriken): enable prefer-primordials for node polyfills
+// deno-lint-ignore-file prefer-primordials
+
import { notImplemented } from "ext:deno_node/_utils.ts";
import { urlToHttpOptions } from "ext:deno_node/internal/url.ts";
import {
@@ -14,14 +17,6 @@ import { type ServerHandler, ServerImpl as HttpServer } from "node:http";
import { validateObject } from "ext:deno_node/internal/validators.mjs";
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
import { Buffer } from "node:buffer";
-import { primordials } from "ext:core/mod.js";
-const {
- ArrayPrototypeShift,
- ArrayPrototypeUnshift,
- ArrayIsArray,
- ObjectPrototypeIsPrototypeOf,
- ObjectAssign,
-} = primordials;
export class Server extends HttpServer {
constructor(opts, requestListener?: ServerHandler) {
@@ -34,11 +29,11 @@ export class Server extends HttpServer {
validateObject(opts, "options");
}
- if (opts.cert && ArrayIsArray(opts.cert)) {
+ if (opts.cert && Array.isArray(opts.cert)) {
notImplemented("https.Server.opts.cert array type");
}
- if (opts.key && ArrayIsArray(opts.key)) {
+ if (opts.key && Array.isArray(opts.key)) {
notImplemented("https.Server.opts.key array type");
}
@@ -47,12 +42,10 @@ export class Server extends HttpServer {
_additionalServeOptions() {
return {
- cert: ObjectPrototypeIsPrototypeOf(Buffer, this._opts.cert)
- // deno-lint-ignore prefer-primordials
+ cert: this._opts.cert instanceof Buffer
? this._opts.cert.toString()
: this._opts.cert,
- key: ObjectPrototypeIsPrototypeOf(Buffer, this._opts.key)
- // deno-lint-ignore prefer-primordials
+ key: this._opts.key instanceof Buffer
? this._opts.key.toString()
: this._opts.key,
};
@@ -166,18 +159,18 @@ export function request(...args: any[]) {
let options = {};
if (typeof args[0] === "string") {
- const urlStr = ArrayPrototypeShift(args);
+ const urlStr = args.shift();
options = urlToHttpOptions(new URL(urlStr));
- } else if (ObjectPrototypeIsPrototypeOf(URL, args[0])) {
- options = urlToHttpOptions(ArrayPrototypeShift(args));
+ } else if (args[0] instanceof URL) {
+ options = urlToHttpOptions(args.shift());
}
if (args[0] && typeof args[0] !== "function") {
- ObjectAssign(options, ArrayPrototypeShift(args));
+ Object.assign(options, args.shift());
}
options._defaultAgent = globalAgent;
- ArrayPrototypeUnshift(args, options);
+ args.unshift(options);
return new HttpsClientRequest(args[0], args[1]);
}