fix: Properly URL-encode labels parameter for API requests

- Add quotes around label values to match API requirements
- Fix label filtering for labels with spaces (e.g. 'aa aa')
- Ensure proper URL encoding as required by server
- Maintains existing pagination and filtering functionality
This commit is contained in:
Ilyas Hallak 2025-10-01 21:36:59 +02:00
parent f42d138f58
commit 3ea4e49686
2 changed files with 8 additions and 8 deletions

View File

@ -241,7 +241,9 @@ class API: PAPI {
} }
if let tag { if let tag {
queryItems.append(URLQueryItem(name: "labels", value: tag)) // URL-encode label with quotes for proper API handling
let encodedTag = "\"\(tag)\""
queryItems.append(URLQueryItem(name: "labels", value: encodedTag))
} }
if !queryItems.isEmpty { if !queryItems.isEmpty {

View File

@ -1,14 +1,12 @@
import Foundation import Foundation
struct LabelUtils { struct LabelUtils {
/// Splits a label input string by spaces and returns individual trimmed labels /// Processes a label input string and returns it as a single trimmed label
/// - Parameter input: The input string containing one or more labels separated by spaces /// - Parameter input: The input string containing a label (spaces are allowed)
/// - Returns: Array of individual trimmed labels, excluding empty strings /// - Returns: Array containing the trimmed label, or empty array if input is empty
static func splitLabelsFromInput(_ input: String) -> [String] { static func splitLabelsFromInput(_ input: String) -> [String] {
return input let trimmed = input.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: " ") return trimmed.isEmpty ? [] : [trimmed]
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
.filter { !$0.isEmpty }
} }
/// Filters out labels that already exist in current or available labels /// Filters out labels that already exist in current or available labels