0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-24 22:05:56 -05:00
logto/packages/console/src/utilities/validator.ts

17 lines
302 B
TypeScript
Raw Normal View History

export const uriValidator = (verifyBlank = true) => {
return (value: string) => {
if (!verifyBlank && value.trim().length === 0) {
return true;
}
try {
// eslint-disable-next-line no-new
new URL(value);
} catch {
return false;
}
return true;
};
};