From 62a11a14d7d37aa6b7c4130f9283c593444fbb40 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 18 Mar 2020 08:12:46 -0400 Subject: [PATCH] Add slash to links to avoid unnecessary redirects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Links to folder content generated by Publish don't seem to end with a trailing "/", which means there will be an additional HTTP redirect request to the resource with the path appended. You can see an example of this by going to https://swiftbysundell.com/articles/the-decade-of-swift in Safari: you will see it redirected to https://swiftbysundell.com/articles/the-decade-of-swift/, which is an unnecessary redirect. This is more obvious when using curl: ```shell marc@bix ~ % curl -v https://swiftbysundell.com/articles/the-decade-of-swift … blah blah blah … < location: https://swiftbysundell.com/articles/the-decade-of-swift/ < 301 Moved Permanently

Moved Permanently

The document has moved here.

* Connection #0 to host swiftbysundell.com left intact * Closing connection 0 ``` TBH, I have no idea of this patch is the correct solution to this inefficiency, but in the absence of an issue tracker, there's no other forum for describing the issue. --- Sources/Publish/API/PlotComponents.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Publish/API/PlotComponents.swift b/Sources/Publish/API/PlotComponents.swift index d3e7de89..2ed9640b 100644 --- a/Sources/Publish/API/PlotComponents.swift +++ b/Sources/Publish/API/PlotComponents.swift @@ -133,7 +133,7 @@ public extension Node where Context: HTMLLinkableContext { /// Assign a path to link the element to, using its `href` attribute. /// - parameter path: The absolute path to assign. static func href(_ path: Path) -> Node { - .href(path.absoluteString) + .href(path.absoluteString + "/") } }