Skip to content
Closed
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Servers/FileServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class FileServer {
xlog("Tried to load an invalid path: \(path).\nFalling back to serve index.html.")
}
mimeType = "text/html"
data = self.data(for: path.appendingPathComponent("/index.html"))
data = self.data(for: "/index.html")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this isn't a change in behavior? What's needless about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only path component of url that data(for:) took as argument was used. The rest of the components are ignored by DocC server implementations.

Additionally, HTTPRequest unlike URLRequest doesn't store full URLs, only paths. The authority and scheme components can be assembled from scheme and authority properties on HTTPRequest , but those aren't used anywhere in the DocC codebase, other than a test in this diff below where we have to construct a new URLRequest to pass it to WKWebView on Darwin platforms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if request.path is "/something" then this used to pass "/something/index.html" as an argument but now it only passes "index.html". Isn't that returning data for the wrong path?

Copy link
Contributor Author

@MaxDesiatov MaxDesiatov Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If request.path is "/something" then that is handled by the if branch above, no this else branch. The latter branch didn't use request.path previously, that logic is unchanged, as verified by the test suite.

}

if let data = data {
Expand Down