UNPKG

@onboardbase/cli

Version:

[![Version](https://img.shields.io/npm/v/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![Downloads/week](https://img.shields.io/npm/dw/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![License](https://img

25 lines (24 loc) 854 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HeaderHostTransformer = void 0; const stream_1 = require("stream"); class HeaderHostTransformer extends stream_1.Transform { constructor(opts) { super(opts); this.host = ""; this.replaced = false; this.host = opts.host || "localhost"; this.replaced = false; } _transform(data, encoding, callback) { callback(null, this.replaced // after replacing the first instance of the Host header we just become a regular passthrough ? data : data .toString() .replace(/(\r\n[Hh]ost: )\S+/, (match, $1) => { this.replaced = true; return $1 + this.host; })); } } exports.HeaderHostTransformer = HeaderHostTransformer;