diff --git a/Sources/SSDPClient/SSDPService.swift b/Sources/SSDPClient/SSDPService.swift index c8d5003..49a3190 100644 --- a/Sources/SSDPClient/SSDPService.swift +++ b/Sources/SSDPClient/SSDPService.swift @@ -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) diff --git a/Tests/SSDPClientTests/SSDPServiceTests.swift b/Tests/SSDPClientTests/SSDPServiceTests.swift index beedccd..cace27d 100644 --- a/Tests/SSDPClientTests/SSDPServiceTests.swift +++ b/Tests/SSDPClientTests/SSDPServiceTests.swift @@ -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() { @@ -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"]) } }