UNPKG

zan-proxy

Version:
20 lines 695 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const url_1 = __importDefault(require("url")); const fillReqURL = (req, protocal = 'http') => { const url = url_1.default.parse(req.url); const host = req.headers.host; url.host = host; url.protocol = protocal; let urlStr = url_1.default.format(url); // 兼容 ws, wss if (protocal.includes('ws')) { urlStr = urlStr.replace(/(wss?:)/, '$1//'); } req.url = urlStr; }; exports.default = fillReqURL; //# sourceMappingURL=fillReqUrl.js.map