mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-23 15:50:26 +01:00
Handle +’s in the query items
+’s in query items can be treated as spaces by services. We want to encode them properly (via URLComponents.enhancedPercentEncodedQuery) This private entension might be worth moving into RSWeb. Fixes #2544
This commit is contained in:
parent
c4cfa5b57e
commit
21c2787f90
@ -111,13 +111,17 @@ final class FeedWranglerAPICaller: NSObject {
|
||||
}
|
||||
|
||||
func renameSubscription(feedID: String, newName: String, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
let url = FeedWranglerConfig.clientURL
|
||||
.appendingPathComponent("subscriptions/rename_feed")
|
||||
.appendingQueryItems([
|
||||
URLQueryItem(name: "feed_id", value: feedID),
|
||||
URLQueryItem(name: "feed_name", value: newName),
|
||||
])
|
||||
|
||||
var postData = URLComponents(url: FeedWranglerConfig.clientURL, resolvingAgainstBaseURL: false)
|
||||
postData?.path += "subscriptions/rename_feed"
|
||||
postData?.queryItems = [
|
||||
URLQueryItem(name: "feed_id", value: feedID),
|
||||
URLQueryItem(name: "feed_name", value: newName),
|
||||
]
|
||||
|
||||
guard let url = postData?.urlWithEnhancedPercentEncodedQuery else {
|
||||
fatalError() // something has gone terribly wrong
|
||||
}
|
||||
|
||||
standardSend(url: url, resultType: FeedWranglerSubscriptionsRequest.self) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
@ -290,3 +294,16 @@ final class FeedWranglerAPICaller: NSObject {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension URLComponents {
|
||||
|
||||
var urlWithEnhancedPercentEncodedQuery: URL? {
|
||||
guard let tempQueryItems = self.queryItems, !tempQueryItems.isEmpty else {
|
||||
return self.url
|
||||
}
|
||||
|
||||
var tempComponents = self
|
||||
tempComponents.percentEncodedQuery = self.enhancedPercentEncodedQuery
|
||||
return tempComponents.url
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user