TF-3734 Fix cannot open email as new tab on safari v16.6

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-05-22 12:58:12 +07:00
committed by Dat H. Pham
parent db7f3ae4d8
commit 798f570491
2 changed files with 34 additions and 7 deletions
+21
View File
@@ -554,4 +554,25 @@ class HtmlUtils {
.replaceAll('\n', '')
.replaceAll('\t', '');
}
/// Returns true if the browser is Safari and its major version is less than 17.
static bool isSafariBelow17() {
try {
final userAgent = html.window.navigator.userAgent;
log('HtmlUtils::isOldSafari:UserAgent = $userAgent');
final isSafari = userAgent.contains('Safari') && !userAgent.contains('Chrome');
if (!isSafari) return false;
final match = RegExp(r'Version/(\d+)\.').firstMatch(userAgent);
if (match == null) return false;
final version = int.tryParse(match.group(1)!);
log('HtmlUtils::isOldSafari:Version = $version');
return version != null && version < 17;
} catch (e) {
logError('HtmlUtils::isOldSafari:Exception = $e');
return false;
}
}
}