Merge branch 'v2.1-dev' as v2.1.2
[squeep-api-dingus] / lib / patches / incoming-message.js
index 894ca65428d79e9ff2ba7decd844d2573c7944d8..1669331f7f7764a369cb6a2127b66404c145be31 100644 (file)
@@ -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()];
   };
 }