isUrl property

bool get isUrl

是否为合法 URL(粗匹配)。

Implementation

bool get isUrl {
  final s = this;
  if (s == null || s.isEmpty) return false;
  const urlPattern =
      r'(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?';
  return RegExp(urlPattern).hasMatch(s);
}