Skip to content

Commit

Permalink
Bugfix: Exporting URIs without escaping slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Oct 10, 2023
1 parent 8f24ae5 commit 4910ccb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Example/Tests/Exporting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 5 additions & 2 deletions nRFMeshProvision/MeshNetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4910ccb

Please sign in to comment.