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);