1 | 'use strict';
|
2 |
|
3 | function isHTTPS(req, trustProxy = true) {
|
4 | const _xForwardedProto = trustProxy && req.headers ? req.headers["x-forwarded-proto"] : void 0;
|
5 | const protoCheck = typeof _xForwardedProto === "string" ? _xForwardedProto.includes("https") : void 0;
|
6 | if (protoCheck) {
|
7 | return true;
|
8 | }
|
9 | const _encrypted = req.connection ? req.connection.encrypted : void 0;
|
10 | const encryptedCheck = _encrypted !== void 0 ? _encrypted === true : void 0;
|
11 | if (encryptedCheck) {
|
12 | return true;
|
13 | }
|
14 | if (protoCheck === void 0 && encryptedCheck === void 0) {
|
15 | return void 0;
|
16 | }
|
17 | return false;
|
18 | }
|
19 |
|
20 | module.exports = isHTTPS;
|