Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct ExternalLocationReference: RenderReference, URLReference {

public let identifier: RenderReferenceIdentifier

let url: String
public var url: String

enum CodingKeys: String, CodingKey {
case type
Expand Down
10 changes: 10 additions & 0 deletions Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,14 @@ class SampleDownloadTests: XCTestCase {
let externalReference = try XCTUnwrap(symbol.references[identifier.identifier] as? ExternalLocationReference)
XCTAssertEqual(externalReference.url, "https://example.com/ExternalLocation.zip")
}

func testRoundTripExternalLocationReferenceWithModifiedURL() throws {
var reference = ExternalLocationReference(identifier: RenderReferenceIdentifier("/test/sample.zip"))
XCTAssertEqual(reference.url, "/test/sample.zip")
reference.url = "https://swift.org/documentation/test/sample.zip"
let encodedReference = try JSONEncoder().encode(reference)
let decodedReference = try JSONDecoder().decode(ExternalLocationReference.self, from: encodedReference)
XCTAssertEqual(decodedReference.identifier.identifier, "/test/sample.zip")
XCTAssertEqual(decodedReference.url, "https://swift.org/documentation/test/sample.zip")
}
}