Skip to content

Commit

Permalink
fix: incorrect parsing #21
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierrick Rouxel committed Jul 29, 2024
1 parent bd13cff commit fc144dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/SSDPClient/SSDPService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SSDPService {
private func parse(_ response: String) -> [String: String] {
var result = [String: String]()

let matches = HeaderRegex.matches(in: response, range: NSRange(location: 0, length: response.count))
let matches = HeaderRegex.matches(in: response, range: NSRange(location: 0, length: response.utf16.count))
for match in matches {
let keyCaptureGroupIndex = match.range(at: 1)
let key = (response as NSString).substring(with: keyCaptureGroupIndex)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SSDPClientTests/SSDPServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SSDPServiceTests: XCTestCase {
XCTAssertNotNil(service.location)
XCTAssertEqual("http://192.168.1.1:10000/root.xml", service.location)
XCTAssertEqual("max-age=120", service.responseHeaders?["CACHE-CONTROL"])
XCTAssertEqual("\"http://schemas.upnp.org/upnp/1/0/\"; ", service.responseHeaders?["OPT"])
XCTAssertEqual("\"http://schemas.upnp.org/upnp/1/0/\"; ns=01", service.responseHeaders?["OPT"])
}

func testParseCaseInsensitive() {
Expand All @@ -55,6 +55,6 @@ class SSDPServiceTests: XCTestCase {
XCTAssertNotNil(service.location)
XCTAssertEqual("http://192.168.1.1:10000/root.xml", service.location)
XCTAssertEqual("max-age=120", service.responseHeaders?["CACHE-CONTROL"])
XCTAssertEqual("\"http://schemas.upnp.org/upnp/1/0/\"; ", service.responseHeaders?["OPT"])
XCTAssertEqual("\"http://schemas.upnp.org/upnp/1/0/\"; ns=01", service.responseHeaders?["OPT"])
}
}

0 comments on commit fc144dc

Please sign in to comment.