Skip to content

Commit

Permalink
feat: add encode url support
Browse files Browse the repository at this point in the history
  • Loading branch information
virgoone authored and jasonraimondi committed May 24, 2024
1 parent 5eb5e4c commit af60eac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ 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());

export const PlainConfigSchema = z.object({
url: z.string().url(),
url: zodStringUrl,
width: z.coerce.number().nullish(),
height: z.coerce.number().nullish(),
viewPortWidth: z.coerce.number().nullish(),
Expand Down

0 comments on commit af60eac

Please sign in to comment.