Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

#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

Open
CasparZheng wants to merge1 commit intoSwiftyJSON:feature/initJsonString
base:feature/initJsonString
Choose a base branch
Loading
fromCasparZheng:initJsonString
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletionsSource/SwiftyJSON.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 if let encodedString_ = self.rawString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) {
// We have to use `Foundation.URL` otherwise it conflicts with the variable name.
return Foundation.URL(string: encodedString_)
} else {
return nil
}else {

Choose a reason for hiding this comment

The 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
Expand Down
3 changes: 3 additions & 0 deletionsTests/SwiftyJSONTests/StringTests.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ class StringTests: XCTestCase {
func testURL() {
let json = JSON("http://github.com")
XCTAssertEqual(json.URL!, URL(string:"http://github.com")!)

Choose a reason for hiding this comment

The 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() {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp