Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix for URLComponents returning nil
* when path contains 'weird' characters (`[]`) URLComponents won't parse it, so the path will be nil
  * escaping the string with `urlQueryAllowed` character set fixes this issue
  • Loading branch information
nejcvivod committed Jul 11, 2019
commit 28b56f05f710b37a04deef8df7bc6fe2954657b9
3 changes: 2 additions & 1 deletion XCode/Sources/HttpParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class HttpParser {
}
let request = HttpRequest()
request.method = statusLineTokens[0]
let urlComponents = URLComponents(string: statusLineTokens[1])
let encodedPath = statusLineTokens[1].addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? statusLineTokens[1]
let urlComponents = URLComponents(string: encodedPath)
request.path = urlComponents?.path ?? ""
request.queryParams = urlComponents?.queryItems?.map { ($0.name, $0.value ?? "") } ?? []
request.headers = try readHeaders(socket)
Expand Down