Skip to content

Commit 11c772e

Browse files
committed
Use URLComponents to build the preview server URL
This allows us to supply the scheme, host and port independently, rather than interpolating them into a string which we then parse.
1 parent 93585b6 commit 11c772e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ public final class PreviewAction: Action, RecreatingContext {
163163
// Preview the output and monitor the source bundle for changes.
164164
do {
165165
print(String(repeating: "=", count: 40), to: &logHandle)
166-
if let previewURL = URL(string: "http://localhost:\(port)") {
166+
var components = URLComponents()
167+
components.scheme = "http"
168+
components.host = "localhost"
169+
components.port = port
170+
if let previewURL = components.url {
167171
print("Starting Local Preview Server", to: &logHandle)
168172
printPreviewAddresses(base: previewURL)
169173
print(String(repeating: "=", count: 40), to: &logHandle)

0 commit comments

Comments
 (0)