Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect encoding of URL components #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/index_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/index_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AlgoliaSettings {
final Algolia algolia;
final String _index;
final Map<String, dynamic> _parameters;
String get encodedIndex => Uri.encodeFull(_index);
String get encodedIndex => Uri.encodeComponent(_index);

AlgoliaSettings _copyWithParameters(Map<String, dynamic> parameters) {
return AlgoliaSettings._(
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions lib/src/object_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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].
///
Expand Down Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AlgoliaQuery {
final Map<String, dynamic> _parameters;

Map<String, dynamic> get parameters => _parameters;
String get encodedIndex => Uri.encodeFull(_index);
String get encodedIndex => Uri.encodeComponent(_index);

AlgoliaQuery _copyWithParameters(Map<String, dynamic> parameters) {
return AlgoliaQuery._(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/synonyms_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down