From 71a15990e2a3d1e8b9ec4dd3f9954236a92430d5 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Sat, 21 Dec 2024 21:35:17 -0500 Subject: [PATCH] Add hashtag awareness to friendica search client --- .../networking/friendica_search_client_services.dart | 8 +++++++- .../networking/friendica_search_client_services.g.dart | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/riverpod_controllers/networking/friendica_search_client_services.dart b/lib/riverpod_controllers/networking/friendica_search_client_services.dart index e88c5e9..00c388e 100644 --- a/lib/riverpod_controllers/networking/friendica_search_client_services.dart +++ b/lib/riverpod_controllers/networking/friendica_search_client_services.dart @@ -45,8 +45,14 @@ Future, ExecError>> searchResults( Future.microtask( () async => ref.read(searchLoadingStatusProvider(profile).notifier).begin(), ); + + var query = searchTerm.trim(); + // query sanitazation? + if (query.startsWith('#')) { + query.replaceFirst('#', '%23'); + } final url = - 'https://${profile.serverName}/api/v1/search?${page.toQueryParameters()}&${type.toQueryParameters()}&q=$searchTerm'; + 'https://${profile.serverName}/api/v1/search?${page.toQueryParameters()}&${type.toQueryParameters()}&q=$query'; final result = await ref.read(getApiPagedRequestProvider( profile, Uri.parse(url), diff --git a/lib/riverpod_controllers/networking/friendica_search_client_services.g.dart b/lib/riverpod_controllers/networking/friendica_search_client_services.g.dart index 056e6b0..009eac0 100644 --- a/lib/riverpod_controllers/networking/friendica_search_client_services.g.dart +++ b/lib/riverpod_controllers/networking/friendica_search_client_services.g.dart @@ -6,7 +6,7 @@ part of 'friendica_search_client_services.dart'; // RiverpodGenerator // ************************************************************************** -String _$searchResultsHash() => r'c7aad55fce75888433ef6afd35ffcd88d7d5b8c4'; +String _$searchResultsHash() => r'56bb101341f50f55e152908e1f3aabf25e842cb4'; /// Copied from Dart SDK class _SystemHash {