Skip to content

Commit

Permalink
fix: validate fallbackUrl as well
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongliang02 committed Nov 19, 2024
1 parent fb00ae5 commit 9a59ec6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/validators/src/url/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodError, ZodSchema, ZodTypeDef } from 'zod'
import { string, ZodError, ZodSchema, ZodTypeDef } from 'zod'

Check failure on line 1 in packages/validators/src/url/index.ts

View workflow job for this annotation

GitHub Actions / lint

'string' is defined but never used
import { fromError } from 'zod-validation-error'

import { OptionsError } from '@/common/errors'
Expand Down Expand Up @@ -79,7 +79,7 @@ export class UrlValidator {
if (error instanceof UrlValidationError && fallbackUrl !== undefined) {
// URL validation failed, return the fallback URL
// This is NOT validated.
return fallbackUrl
return this.#parse(fallbackUrl instanceof URL ? fallbackUrl.href : fallbackUrl)
}
// otherwise rethrow
throw error
Expand Down

0 comments on commit 9a59ec6

Please sign in to comment.