From 62930a714c8bf47f02809d671dfb5e280291a47d Mon Sep 17 00:00:00 2001 From: Hiddify Date: Fri, 15 Sep 2023 15:18:32 +0200 Subject: [PATCH] fix: bug in get headers from body --- lib/data/repository/profiles_repository_impl.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/data/repository/profiles_repository_impl.dart b/lib/data/repository/profiles_repository_impl.dart index dd11ce7d..f350228e 100644 --- a/lib/data/repository/profiles_repository_impl.dart +++ b/lib/data/repository/profiles_repository_impl.dart @@ -182,6 +182,8 @@ class ProfilesRepositoryImpl () async { final path = filesEditor.configPath(fileName); final response = await dio.download(url.trim(), path); + final content = await File(path).readAsString(); + final headers = addHeadersFromBody(response.headers.map, content); final parseResult = await singbox.parseConfig(path).run(); return parseResult.fold( (l) async { @@ -190,9 +192,6 @@ class ProfilesRepositoryImpl return left(ProfileFailure.invalidConfig(l.msg)); }, (_) async { - final responseString = await File(path).readAsString(); - final headers = - addHeadersFromBody(response.headers.map, responseString); final profile = Profile.fromResponse(url, headers); return right(profile); }, @@ -215,6 +214,7 @@ class ProfilesRepositoryImpl 'profile-web-page-url', ]; for (final text in content.split("\n")) { + print(text); if (text.startsWith("#") || text.startsWith("//")) { final index = text.indexOf(':'); if (index == -1) continue;