Add hiddify deeplink
This commit is contained in:
@@ -105,7 +105,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
final captureResult =
|
||||
await Clipboard.getData(Clipboard.kTextPlain);
|
||||
final link =
|
||||
LinkParser.simple(captureResult?.text ?? '');
|
||||
LinkParser.parse(captureResult?.text ?? '');
|
||||
if (link != null && context.mounted) {
|
||||
if (addProfileMutation.state.isInProgress) return;
|
||||
mutationTriggered.value = true;
|
||||
@@ -115,9 +115,11 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
.addProfile(link.url),
|
||||
);
|
||||
} else {
|
||||
CustomToast.error(
|
||||
t.profile.add.invalidUrlMsg.sentenceCase,
|
||||
).show(context);
|
||||
if (context.mounted) {
|
||||
CustomToast.error(
|
||||
t.profile.add.invalidUrlMsg.sentenceCase,
|
||||
).show(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user