Skip to content

Commit

Permalink
Revert "fix(ext/node): use primordials in `ext/node/polyfills/https.t…
Browse files Browse the repository at this point in the history
…s` (#26323)" (#26613)

…s` (#26323)"

This reverts commit afb33b3.

Reverting because it caused a regression -
#26612.

Closes #26612.
  • Loading branch information
bartlomieju committed Oct 29, 2024
1 parent 9f9eec1 commit a2dacc7
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions ext/node/polyfills/https.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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) {
Expand All @@ -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");
}

Expand All @@ -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,
};
Expand Down Expand Up @@ -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]);
}
Expand Down

0 comments on commit a2dacc7

Please sign in to comment.