Fix url encoder by specifying allowed characters#51
Conversation
JohnSundell
left a comment
There was a problem hiding this comment.
Nice fix 👍 Some comments inline, let me know what you think 🙂
| @@ -1,4 +1,8 @@ | |||
| import Foundation | |||
| #if os(OSX) | |||
| import Cocoa | |||
There was a problem hiding this comment.
How come this is needed, since you have only removed code from this file?
There was a problem hiding this comment.
Good catch. I added it by mistake. Will remove it
| @@ -0,0 +1,25 @@ | |||
| import Foundation | |||
|
|
|||
| struct Utilities { | |||
There was a problem hiding this comment.
I would suggest using a different name than Utilities (which is both very ambiguous, and tends to be a "catch all" for all kinds of unrelated APIs). Since these utilities are all about encoding strings, how about implementing them in an extension on String?
There was a problem hiding this comment.
Ironically 😛 I just moved those from string extensions to a new class. I had some problem before when some frameworks have the same method on String
There was a problem hiding this comment.
Yeah, that's a valid point. In that case, how about a StringEncoder class or something like that?
There was a problem hiding this comment.
Yeah, I can add that
|
|
||
| /// Perform url encoding | ||
| /// | ||
| /// - Parameter string: The source string |
There was a problem hiding this comment.
Also I'd name that parameter allowedCharacters, since just allowed is a bit ambiguous in this context.
There was a problem hiding this comment.
Also why not just pass a CharacterSet, just like to String?
There was a problem hiding this comment.
You're right, I will add that
delimiterUtilitiesto do encoding. Also covered by tests 😎 . Run on Xcode 8 and Xcode 9open(url)methods, as they are internal now