Skip to content

Commit b6b057d

Browse files
committed
allow localhost
1 parent 7f60dd8 commit b6b057d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/server/utils/validator.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ export const checkAndReturnNFTSignaturePayload = <
9393
export const isValidWebhookUrl = (input: string): boolean => {
9494
try {
9595
const url = new URL(input);
96-
return url.protocol === "https:";
96+
return (
97+
url.protocol === "https:" ||
98+
// Allow http for localhost only.
99+
(url.protocol === "http:" &&
100+
["localhost", "0.0.0.0", "127.0.0.1"].includes(url.hostname))
101+
);
97102
} catch {
98103
return false;
99104
}

src/tests/validator.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ describe("isValidWebhookUrl", () => {
2525
it("should return false for an empty string", () => {
2626
expect(isValidWebhookUrl("")).toBe(false);
2727
});
28+
29+
it("should return true for a http localhost", () => {
30+
expect(isValidWebhookUrl("http://localhost:3000")).toBe(true);
31+
expect(isValidWebhookUrl("http://0.0.0.0:3000")).toBe(true);
32+
expect(isValidWebhookUrl("http://user:[email protected]:3000")).toBe(true);
33+
});
2834
});

0 commit comments

Comments
 (0)