mirror of
https://github.com/logto-io/logto.git
synced 2025-02-24 22:05:56 -05:00
17 lines
302 B
TypeScript
17 lines
302 B
TypeScript
|
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;
|
||
|
};
|
||
|
};
|