add content-disposition for profile title

This commit is contained in:
Hiddify
2023-09-10 09:54:25 +02:00
parent 40901dce96
commit 6fc52bcee1

View File

@@ -42,6 +42,18 @@ class Profile with _$Profile {
title = titleHeader;
}
}
if (title.isEmpty) {
final contentDisposition = headers['content-disposition']?.single;
if (contentDisposition != null) {
final RegExp regExp = RegExp(r'filename="([^"]*)"');
final match = regExp.firstMatch(contentDisposition);
if (match != null && match.groupCount >= 1) {
title = match.group(1) ?? '';
}
}
}
if (title.isEmpty) {
final part = url.split("/").lastOrNull;
if (part != null) {