mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
Updates the current regex based approach for validating redirect urls to instead use the native URL constructor which is available in browsers and Node.js and handles several valid cases that were previously not working.
13 lines
375 B
TypeScript
13 lines
375 B
TypeScript
import { z } from 'zod';
|
|
|
|
import { isValidRedirectUrl } from '../utils/is-valid-redirect-url';
|
|
|
|
/**
|
|
* Note this allows empty strings.
|
|
*/
|
|
export const ZUrlSchema = z
|
|
.string()
|
|
.refine((value) => value === undefined || value === '' || isValidRedirectUrl(value), {
|
|
message: 'Please enter a valid URL, make sure you include http:// or https:// part of the url.',
|
|
});
|