Adjust url encode for +

This commit is contained in:
Daniel Saidi 2022-02-10 20:00:52 +01:00
parent c3d401059a
commit af91f7dc5a
2 changed files with 3 additions and 3 deletions

View File

@ -6,8 +6,7 @@
### ✨ New features
* `String+Characters` contains single-char characters like `newLine` and `tab`.
* `String+Subscript` contains functionality for accessing chars in a String.
* `String+Subscript` contains functionality for accessing chars in a String.
## 1.0

View File

@ -17,10 +17,11 @@ public extension String {
This will first call `addingPercentEncoding`, using the
`.urlPathAllowed` character set, then replace every `&`
with `%26`.
with `%26` and + with %2B.
*/
func urlEncoded() -> String? {
addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)?
.replacingOccurrences(of: "&", with: "%26")
.replacingOccurrences(of: "+", with: "%2B")
}
}