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:
parent
f42d138f58
commit
3ea4e49686
@ -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 {
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user