Rocket.Chat.ReactNative/app/lib/methods/helpers/isValidUrl.ts

10 lines
186 B
TypeScript

import { URL } from 'react-native-url-polyfill';
export const isValidUrl = (link: string): boolean => {
try {
return Boolean(new URL(link));
} catch (error) {
return false;
}
};