Skip to content

Commit 0ea68cc

Browse files
committed
fix formatting
1 parent d24f421 commit 0ea68cc

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

request.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ Deno.test({
310310
Deno.test({
311311
name: "request.x-forwarded-for - caps entries and is performant",
312312
fn() {
313-
const manyIps = Array.from({ length: 1000 }, (_, i) => `10.0.0.${i}`).join(", ");
313+
const manyIps = Array.from({ length: 1000 }, (_, i) => `10.0.0.${i}`).join(
314+
", ",
315+
);
314316
const request = new Request(
315317
createMockNativeRequest("https://example.com/index.html", {
316318
headers: {

request.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ export class Request {
8484
get ips(): string[] {
8585
return this.#proxy
8686
? (() => {
87-
const raw = this.#serverRequest.headers.get("x-forwarded-for") ?? this.#getRemoteAddr();
88-
const bounded = raw.length > 4096 ? raw.slice(0, 4096) : raw;
89-
return bounded
90-
.split(",", 100)
91-
.map((part) => part.trim())
92-
.filter((part) => part.length > 0);
93-
})()
87+
const raw = this.#serverRequest.headers.get("x-forwarded-for") ??
88+
this.#getRemoteAddr();
89+
const bounded = raw.length > 4096 ? raw.slice(0, 4096) : raw;
90+
return bounded
91+
.split(",", 100)
92+
.map((part) => part.trim())
93+
.filter((part) => part.length > 0);
94+
})()
9495
: [];
9596
}
9697

@@ -144,7 +145,9 @@ export class Request {
144145
let proto: string;
145146
let host: string;
146147
if (this.#proxy) {
147-
const xForwardedProto = serverRequest.headers.get("x-forwarded-proto");
148+
const xForwardedProto = serverRequest.headers.get(
149+
"x-forwarded-proto",
150+
);
148151
let maybeProto = xForwardedProto
149152
? xForwardedProto.split(",", 1)[0].trim().toLowerCase()
150153
: undefined;

0 commit comments

Comments
 (0)