Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/lib/__tests__/rateLimit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,30 @@ describe("getClientIp", () => {
});
expect(getClientIp(req)).toBe("unknown");
});

it.each([
["out of bounds segment", "256.256.256.256"],
["too few segments", "1.2.3"],
["too many segments", "1.2.3.4.5"],
["empty segment", "1..3.4"],
["negative number", "-1.2.3.4"],
["contains letters", "1.2.a.4"],
["leading zeros", "192.168.01.1"],
])("returns unknown for malformed IPv4 address: %s", (_, forwardedFor) => {
const req = new Request("http://localhost", {
headers: {
"x-forwarded-for": forwardedFor
}
});
expect(getClientIp(req)).toBe("unknown");
});

it("returns unknown for invalid IPv6 URL malformed address", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 テスト名に冗長な表現があります。invalidmalformed は同義語であるため、「invalid IPv6 URL malformed address」は意味が重複しています。より簡潔な名称にした方が読みやすくなります。

Suggested change
it("returns unknown for invalid IPv6 URL malformed address", () => {
it("returns unknown for malformed IPv6 address", () => {
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/__tests__/rateLimit.test.ts
Line: 220

Comment:
テスト名に冗長な表現があります。`invalid``malformed` は同義語であるため、「invalid IPv6 URL malformed address」は意味が重複しています。より簡潔な名称にした方が読みやすくなります。

```suggestion
    it("returns unknown for malformed IPv6 address", () => {
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

const req = new Request("http://localhost", {
headers: {
"x-forwarded-for": "123:456:789:abc:def:gh:ij:kl"
}
});
expect(getClientIp(req)).toBe("unknown");
});
});
Loading