Skip to content

Commit 74ade1e

Browse files
committed
Improved proxy builder
1 parent 528af17 commit 74ade1e

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/server/helpers/build-response.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function buildResponse(state: Partial<ResponseState>): KrasAnswer {
7171
const redirectUrl = state.redirectUrl;
7272
const headers = state.headers || {};
7373
const injector = state.injector || {};
74+
7475
setIfUndefined(headers, 'content-type', 'text/html');
7576
setIfUndefined(injector, 'name', '(none)');
7677

@@ -85,18 +86,11 @@ function buildResponse(state: Partial<ResponseState>): KrasAnswer {
8586
}
8687

8788
export function fromNode(ans: NodeResponse, body: Buffer, injector?: KrasInjectorInfo) {
88-
const headers: Headers = {};
89-
90-
Object.keys(ans.headers).forEach((name) => {
91-
const value = ans.headers[name];
92-
headers[name] = Array.isArray(value) ? value.join() : value;
93-
});
94-
9589
return buildResponse({
9690
statusCode: ans.statusCode,
9791
statusText: ans.statusMessage,
9892
url: ans.url || ans.request.href,
99-
headers,
93+
headers: ans.headers,
10094
content: body,
10195
injector,
10296
});

src/server/helpers/compare-requests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function pathEquals(a: string, b: string) {
2626

2727
if (i === b.indexOf('?')) {
2828
if (i !== -1) {
29-
a = a.substr(0, i);
30-
b = b.substr(0, i);
29+
a = a.substring(0, i);
30+
b = b.substring(0, i);
3131
}
3232

3333
return stringEquals(a, b);

0 commit comments

Comments
 (0)