From 18e9c30e1cfb70b3ca1389c3d36703349697e828 Mon Sep 17 00:00:00 2001 From: Jason Raimondi Date: Mon, 3 Jun 2024 22:19:49 -0400 Subject: [PATCH] revert: revert url schema changes, add tests encoded urls were always supported --- src/lib/schema.ts | 11 +---------- tests/app.spec.ts | 7 +++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/lib/schema.ts b/src/lib/schema.ts index ff0f939..95dc938 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -7,16 +7,7 @@ const zodStringBool = z .transform(x => x === "true") .pipe(z.boolean()); -const zodStringUrl = z - .string() - .transform(value => { - try { - return decodeURIComponent(value); - } catch (error) { - return value; - } - }) - .pipe(z.string().url()); +const zodStringUrl = z.string().url(); export const PlainConfigSchema = z.object({ url: zodStringUrl, diff --git a/tests/app.spec.ts b/tests/app.spec.ts index e6ae19d..98c57d7 100644 --- a/tests/app.spec.ts +++ b/tests/app.spec.ts @@ -59,6 +59,13 @@ suite("app", () => { expect(res.status).toBe(200); }); + it("succeeds with uri encoded url", async () => { + const url = encodeURIComponent("https://jasonraimondi.com"); + const res = await app.request(`/?url=${url}`); + console.log(`/?url=${url}`) + expect(res.status).toBe(200); + }); + it("throws when invalid domain", async () => { const res = await app.request("/?url=bar"); expect(res.status).toBe(400);