fix: image url check for embed link (#4826)

* fix: image url check in for embed link

* chore: move all patterns to shared

* test: prefer enterText over manipulating widget
This commit is contained in:
Mathias Mogensen
2024-03-06 16:31:30 +01:00
committed by GitHub
parent 6e2caf3358
commit f5cb8b6d25
13 changed files with 104 additions and 75 deletions

View File

@ -1,10 +1,12 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy_backend/log.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as p;
import '../../../startup/tasks/prelude.dart';
@ -26,7 +28,7 @@ class ApplicationDataStorage {
if (Platform.isMacOS) {
// remove the prefix `/Volumes/*`
path = path.replaceFirst(RegExp('^/Volumes/[^/]+'), '');
path = path.replaceFirst(macOSVolumesRegex, '');
} else if (Platform.isWindows) {
path = path.replaceAll('/', '\\');
}

View File

@ -1,18 +0,0 @@
/// RegExp to match Twelve Hour formats
/// Source: https://stackoverflow.com/a/33906224
///
/// Matches eg: "05:05 PM", "5:50 Pm", "10:59 am", etc.
///
final _twelveHourTimePattern =
RegExp(r'\b((1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm]))');
bool isTwelveHourTime(String? time) =>
_twelveHourTimePattern.hasMatch(time ?? '');
/// RegExp to match Twenty Four Hour formats
/// Source: https://stackoverflow.com/a/7536768
///
/// Matches eg: "0:01", "04:59", "16:30", etc.
///
final _twentyFourHourtimePattern = RegExp(r'^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$');
bool isTwentyFourHourTime(String? time) =>
_twentyFourHourtimePattern.hasMatch(time ?? '');