Skip to content

Commit

Permalink
revert: revert url schema changes, add tests
Browse files Browse the repository at this point in the history
encoded urls were always supported
  • Loading branch information
jasonraimondi committed Jun 4, 2024
1 parent 451a130 commit 18e9c30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
11 changes: 1 addition & 10 deletions src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions tests/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 18e9c30

Please # to comment.