Skip to content
Merged
Changes from all 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
6 changes: 3 additions & 3 deletions Sources/WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelega
request.setValue("\(url.host!):\(port!)", forHTTPHeaderField: headerWSHostName)

var path = url.absoluteString
let offset = (url.scheme?.characters.count ?? 2) + 3
let offset = (url.scheme?.count ?? 2) + 3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will break for anyone not yet on Xcode 9. Might be best to do the following instead:

#if swift(>=3.2)
let offset = (url.scheme?.count ?? 2) + 3
#else
let offset = (url.scheme?.characters.count ?? 2) + 3
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind just saw we're already Swift 4 🙂

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deprecation message actually is only in Xcode 9.1 but let's get ready for it. ;)

path = String(path[path.index(path.startIndex, offsetBy: offset)..<path.endIndex])
if let range = path.range(of: "/") {
path = String(path[range.lowerBound..<path.endIndex])
Expand Down Expand Up @@ -807,8 +807,8 @@ open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelega
}

if let acceptKey = headers[headerWSAcceptName.lowercased()] {
if acceptKey.characters.count > 0 {
if headerSecKey.characters.count > 0 {
if acceptKey.count > 0 {
if headerSecKey.count > 0 {
let sha = "\(headerSecKey)258EAFA5-E914-47DA-95CA-C5AB0DC85B11".sha1Base64()
if sha != acceptKey as String {
return -1
Expand Down