Add hiddify deeplink

This commit is contained in:
problematicconsumer
2023-08-27 10:49:34 +03:30
parent 5acd5889f3
commit 4f5c6c12a5
4 changed files with 24 additions and 14 deletions

View File

@@ -5,7 +5,11 @@ typedef ProfileLink = ({String url, String name});
// TODO: test and improve
abstract class LinkParser {
static const protocols = ['clash', 'clashmeta', 'sing-box'];
static const protocols = ['clash', 'clashmeta', 'sing-box', 'hiddify'];
static ProfileLink? parse(String link) {
return simple(link) ?? deep(link);
}
static ProfileLink? simple(String link) {
if (!isUrl(link)) return null;
@@ -35,6 +39,11 @@ abstract class LinkParser {
if (uri.authority != 'import-remote-profile' ||
!queryParams.containsKey('url')) return null;
return (url: queryParams['url']!, name: queryParams['name'] ?? '');
case 'hiddify':
if ((uri.authority != 'install-config' &&
uri.authority != 'install-sub') ||
!queryParams.containsKey('url')) return null;
return (url: queryParams['url']!, name: queryParams['name'] ?? '');
default:
return null;
}