X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpatches%2Fincoming-message.js;h=1669331f7f7764a369cb6a2127b66404c145be31;hb=refs%2Fheads%2Fmaster;hp=894ca65428d79e9ff2ba7decd844d2573c7944d8;hpb=29837f0eeb9fcb4c53426e5bd89e9bdf7e9d961b;p=squeep-api-dingus diff --git a/lib/patches/incoming-message.js b/lib/patches/incoming-message.js index 894ca65..1669331 100644 --- a/lib/patches/incoming-message.js +++ b/lib/patches/incoming-message.js @@ -1,17 +1,17 @@ 'use strict'; -const { IncomingMessage } = require('http'); +const { IncomingMessage } = require('node:http'); /** * Welp, here we are, already into the crazy. - * Per documentation (https://nodejs.org/docs/latest-v12.x/api/http.html#http_request_getheader_name) - * this should exist, yet (as of 12.18.4) it does not. So let us change this pitch up, and patch -*/ + * This originally existed due to a misinterpretation of the documentation, + * but it's really quite useful, so it stays in our world. + */ /* istanbul ignore else */ if (typeof IncomingMessage.getHeader !== 'function') { IncomingMessage.prototype.getHeader = function (name) { if (typeof name !== 'string') { throw new TypeError('\'name\' must be a string'); } - return this.headers && this.headers[name.toLowerCase()]; + return this.headers?.[name.toLowerCase()]; }; }