From 6fc52bcee1eabe0be1205f4be4b2676a91b7ba68 Mon Sep 17 00:00:00 2001 From: Hiddify Date: Sun, 10 Sep 2023 09:54:25 +0200 Subject: [PATCH] add content-disposition for profile title --- lib/domain/profiles/profile.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/domain/profiles/profile.dart b/lib/domain/profiles/profile.dart index 0f265a11..631dc81b 100644 --- a/lib/domain/profiles/profile.dart +++ b/lib/domain/profiles/profile.dart @@ -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) {