- Notifications
You must be signed in to change notification settings - Fork3.4k
#964 solution#965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:feature/initJsonString
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
#964 solution#965
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -977,11 +977,15 @@ extension JSON { | ||
| // Check for existing percent escapes first to prevent double-escaping of % character | ||
| if let _ = self.rawString.range(of: "%[0-9A-Fa-f]{2}", options: .regularExpression, range: nil, locale: nil) { | ||
| return Foundation.URL(string: self.rawString) | ||
| }else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Statement Position Violation: Else and catch should be on the same line, one space after the previous declaration. (statement_position) | ||
| var charSet = CharacterSet.urlQueryAllowed | ||
| charSet.insert(charactersIn: "#") | ||
| if let encodedString_ = self.rawString.addingPercentEncoding(withAllowedCharacters: charSet) { | ||
| // We have to use `Foundation.URL` otherwise it conflicts with the variable name. | ||
| return Foundation.URL(string: encodedString_) | ||
| } else { | ||
| return nil | ||
| } | ||
| } | ||
| default: | ||
| return nil | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -39,6 +39,9 @@ class StringTests: XCTestCase { | ||
| func testURL() { | ||
| let json = JSON("http://github.com") | ||
| XCTAssertEqual(json.URL!, URL(string:"http://github.com")!) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) | ||
| let json2 = JSON("http://github.com#location") | ||
| XCTAssertEqual(json2.url!, URL(string: "http://github.com#location")) | ||
| } | ||
| func testBool() { | ||