mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Parse links
This commit is contained in:
		@@ -11,3 +11,19 @@ bool validateEmail(String value) {
 | 
			
		||||
  RegExp regex = new RegExp(pattern);
 | 
			
		||||
  return regex.hasMatch(value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Check out whether a given string is a valid URL or not
 | 
			
		||||
bool validateUrl(String url) {
 | 
			
		||||
  //Initial check
 | 
			
		||||
  if (!url.startsWith("http://") && !url.startsWith("https://")) return false;
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
    final uri = Uri.parse(url);
 | 
			
		||||
    return uri.hasScheme &&
 | 
			
		||||
        uri.hasAuthority &&
 | 
			
		||||
        uri.port != 0 &&
 | 
			
		||||
        uri.path.length != 0;
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user