Skip to content

Commit 3390fe0

Browse files
mattstromMatt Strom
andauthored
build: fix typescript error (#521)
* build: fix typescript error * chore: housekeeping Co-authored-by: Matt Strom <[email protected]>
1 parent 85c8921 commit 3390fe0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/behavior-router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ export class BehaviorRouter {
177177
res.setHeader(key as string, value);
178178
}
179179
}
180-
180+
181181
if (response.bodyEncoding === 'base64') {
182-
res.end(Buffer.from(response.body, 'base64').toString('utf-8'));
182+
res.end(Buffer.from(response.body ?? '', 'base64').toString('utf-8'));
183183
} else {
184184
res.end(response.body);
185185
}

src/services/origin.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import * as fs from 'fs-extra';
33
import * as http from 'http';
44
import * as https from 'https';
55
import * as path from 'path';
6-
76
import { parse } from 'url';
7+
88
import { toHttpHeaders } from '../utils';
99
import { OutgoingHttpHeaders } from 'http';
1010
import { InternalServerError, NotFoundError } from '../errors/http';
@@ -15,8 +15,6 @@ export class Origin {
1515
private readonly type: 'http' | 'https' | 'file' | 'noop' = 'http';
1616

1717
constructor(public readonly baseUrl: string = '') {
18-
const regex = /^https?:\/\//;
19-
2018
if (!baseUrl) {
2119
this.type = 'noop';
2220
} else if (/^http:\/\//.test(baseUrl)) {
@@ -50,6 +48,7 @@ export class Origin {
5048
// Make sure error gets back to user
5149
const status = err.statusCode || StatusCodes.INTERNAL_SERVER_ERROR;
5250
const reasonPhrase = err.reasonPhrase || 'Internal Server Error';
51+
5352
return {
5453
status: status,
5554
statusDescription: reasonPhrase,
@@ -144,9 +143,11 @@ export class Origin {
144143
});
145144
res.on('error', (err: Error) => reject(err));
146145
});
146+
147147
if (request.body && request.body.data) {
148148
req.write(request.body.data);
149149
}
150+
150151
req.end();
151152
});
152153
}

0 commit comments

Comments
 (0)