Skip to content

Commit 0af9644

Browse files
committed
fix: query url encoding issue with plus sign (#772)
1 parent cca3c76 commit 0af9644

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/AlgoliaSearchClient/Models/Search/Query/Query+URLEncodable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ extension Query {
103103
func encode() -> String? {
104104
var components = URLComponents()
105105
components.queryItems = queryItems
106-
return components.percentEncodedQuery
106+
return components.query?.addingPercentEncoding(withAllowedCharacters: .uriAllowed)
107107
}
108108

109109
}

Tests/AlgoliaSearchClientTests/Unit/QueryTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class QueryTests: XCTestCase {
1919
.set(\.explainModules, to: [.matchAlternatives])
2020
.set(\.attributesToRetrieve, to: ["attr1", "attr2", "attr3"])
2121
.set(\.restrictSearchableAttributes, to: ["rattr1", "rattr2"])
22-
.set(\.filters, to: "(color:red OR color:yellow) AND on-sale")
22+
.set(\.filters, to: "(color:red OR color:yellow) AND on-sale AND 12+")
2323
.set(\.facetFilters, to: [.or("color:red", "color:blue"), "size:M"])
2424
.set(\.optionalFilters, to: [.or("color:red", "color:yellow"), "on-sale"])
2525
.set(\.numericFilters, to: [.or("price>100", "length<1000"), "metrics>5"])
@@ -95,7 +95,7 @@ class QueryTests: XCTestCase {
9595
"explainModules=match.alternatives",
9696
"attributesToRetrieve=attr1,attr2,attr3",
9797
"restrictSearchableAttributes=rattr1,rattr2",
98-
"filters=(color:red%20OR%20color:yellow)%20AND%20on-sale",
98+
"filters=(color:red%20OR%20color:yellow)%20AND%20on-sale%20AND%2012%2B",
9999
"facetFilters=%5B%5B%22color:red%22,%22color:blue%22%5D,%22size:M%22%5D",
100100
"optionalFilters=%5B%5B%22color:red%22,%22color:yellow%22%5D,%22on-sale%22%5D",
101101
"numericFilters=%5B%5B%22price%3E100%22,%22length%3C1000%22%5D,%22metrics%3E5%22%5D",
@@ -189,7 +189,7 @@ class QueryTests: XCTestCase {
189189
"explainModules": ["match.alternatives"],
190190
"attributesToRetrieve": ["attr1", "attr2", "attr3"],
191191
"restrictSearchableAttributes": ["rattr1", "rattr2"],
192-
"filters": "(color:red OR color:yellow) AND on-sale",
192+
"filters": "(color:red OR color:yellow) AND on-sale AND 12+",
193193
"facetFilters": [["color:red", "color:blue"], "size:M"],
194194
"optionalFilters": [["color:red", "color:yellow"], "on-sale"],
195195
"numericFilters": [["price>100", "length<1000"], "metrics>5"],

0 commit comments

Comments
 (0)