From 2543080f6ba21f0d70d854d7faaf5656ec6cc5a4 Mon Sep 17 00:00:00 2001 From: Kjartan Ferstl Date: Sat, 29 Jun 2024 09:10:58 +0200 Subject: [PATCH] Fix incorrect encoding of URL components --- lib/src/index_reference.dart | 2 +- lib/src/index_settings.dart | 4 ++-- lib/src/object_reference.dart | 6 +++--- lib/src/query.dart | 2 +- lib/src/synonyms_reference.dart | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/index_reference.dart b/lib/src/index_reference.dart index 29323b3..24e5f56 100644 --- a/lib/src/index_reference.dart +++ b/lib/src/index_reference.dart @@ -87,7 +87,7 @@ class AlgoliaIndexReference extends AlgoliaQuery { }) async { var response = await algolia._apiCall( ApiRequestType.post, - 'indexes/$encodedIndex/facets/${Uri.encodeFull(facetName)}/query', + 'indexes/$encodedIndex/facets/${Uri.encodeComponent(facetName)}/query', data: { 'params': params, 'facetQuery': facetQuery, diff --git a/lib/src/index_settings.dart b/lib/src/index_settings.dart index c5fbc09..68a444b 100644 --- a/lib/src/index_settings.dart +++ b/lib/src/index_settings.dart @@ -44,7 +44,7 @@ class AlgoliaSettings { final Algolia algolia; final String _index; final Map _parameters; - String get encodedIndex => Uri.encodeFull(_index); + String get encodedIndex => Uri.encodeComponent(_index); AlgoliaSettings _copyWithParameters(Map parameters) { return AlgoliaSettings._( @@ -60,7 +60,7 @@ class AlgoliaSettings { String toString() { return { 'url': '${algolia._host}indexes' + - (_index.isNotEmpty ? '/' + Uri.encodeFull(_index) : ''), + (_index.isNotEmpty ? '/' + Uri.encodeComponent(_index) : ''), 'headers': algolia._headers, 'parameters': _parameters, }.toString(); diff --git a/lib/src/object_reference.dart b/lib/src/object_reference.dart index 5474f02..67581e6 100644 --- a/lib/src/object_reference.dart +++ b/lib/src/object_reference.dart @@ -14,8 +14,8 @@ class AlgoliaObjectReference { String? get objectID => _objectId; String? get encodedObjectID => - _objectId != null ? Uri.encodeFull(_objectId!) : null; - String? get encodedIndex => _index != null ? Uri.encodeFull(_index!) : null; + _objectId != null ? Uri.encodeComponent(_objectId!) : null; + String? get encodedIndex => _index != null ? Uri.encodeComponent(_index!) : null; /// Get the object referred to by this [AlgoliaObjectReference]. /// @@ -47,7 +47,7 @@ class AlgoliaObjectReference { url += '/$encodedObjectID'; } if (data['objectID'] != null && _objectId == null) { - url += "/${Uri.encodeFull(data['objectID'])}"; + url += "/${Uri.encodeComponent(data['objectID'])}"; } else if (data['objectID'] != null) { data.remove('objectID'); } diff --git a/lib/src/query.dart b/lib/src/query.dart index 8d8d809..6a7856a 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -31,7 +31,7 @@ class AlgoliaQuery { final Map _parameters; Map get parameters => _parameters; - String get encodedIndex => Uri.encodeFull(_index); + String get encodedIndex => Uri.encodeComponent(_index); AlgoliaQuery _copyWithParameters(Map parameters) { return AlgoliaQuery._( diff --git a/lib/src/synonyms_reference.dart b/lib/src/synonyms_reference.dart index d1b7aba..d13e917 100644 --- a/lib/src/synonyms_reference.dart +++ b/lib/src/synonyms_reference.dart @@ -32,7 +32,7 @@ class AlgoliaSynonymsReference { /// /// ID of the referenced index. /// - String get encodedIndex => Uri.encodeFull(index); + String get encodedIndex => Uri.encodeComponent(index); /// /// **Search synonyms**