From 4910ccbf8b4186b95f87bf52e71dbbb505d5b6fe Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Tue, 10 Oct 2023 14:02:41 +0200 Subject: [PATCH] Bugfix: Exporting URIs without escaping slashes --- Example/Tests/Exporting.swift | 1 + nRFMeshProvision/MeshNetworkManager.swift | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Example/Tests/Exporting.swift b/Example/Tests/Exporting.swift index 600cf08b9..60e420cc5 100644 --- a/Example/Tests/Exporting.swift +++ b/Example/Tests/Exporting.swift @@ -419,6 +419,7 @@ class Exporting: XCTestCase { // Compare the generated JSON outputs. let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 + encoder.outputFormatting = .withoutEscapingSlashes var originalData, copyData: Data? XCTAssertNoThrow(originalData = try encoder.encode(meshNetwork)) diff --git a/nRFMeshProvision/MeshNetworkManager.swift b/nRFMeshProvision/MeshNetworkManager.swift index 49eeb09fb..d83f3ec5c 100644 --- a/nRFMeshProvision/MeshNetworkManager.swift +++ b/nRFMeshProvision/MeshNetworkManager.swift @@ -1171,6 +1171,7 @@ public extension MeshNetworkManager { func save() -> Bool { let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 + encoder.outputFormatting = .withoutEscapingSlashes let data = try! encoder.encode(meshData) return storage.save(data) @@ -1203,8 +1204,9 @@ public extension MeshNetworkManager { func export() -> Data { let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 + encoder.outputFormatting = .withoutEscapingSlashes if #available(iOS 11.0, *) { - encoder.outputFormatting = .sortedKeys + encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes] } return try! encoder.encode(meshData.meshNetwork) @@ -1232,8 +1234,9 @@ public extension MeshNetworkManager { func export(_ configuration: ExportConfiguration) -> Data { let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 + encoder.outputFormatting = .withoutEscapingSlashes if #available(iOS 11.0, *) { - encoder.outputFormatting = .sortedKeys + encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes] } let meshNetwork = meshData.meshNetwork?.copy(using: configuration)