diff --git a/Library/Sources/Internal/Middlewares/DocCMiddleware.swift b/Library/Sources/Internal/Middlewares/DocCMiddleware.swift index 8400241..db9d8fb 100644 --- a/Library/Sources/Internal/Middlewares/DocCMiddleware.swift +++ b/Library/Sources/Internal/Middlewares/DocCMiddleware.swift @@ -70,7 +70,11 @@ struct DocCMiddleware< // rule #5: Redirects URI resources with `/` to `/documentation`. if uriResource == .forwardSlash { - return .redirect(to: String(format: .Format.Path.documentation, uriPath)) + return if uriPath.hasSuffix(.forwardSlash) { + .redirect(to: String(format: .Format.Path.documentation, uriPath)) + } else { + .redirect(to: String(format: .Format.Path.forwardSlash, uriPath)) + } } for staticFile in StaticFile.allCases { diff --git a/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift b/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift index 2371d96..bffecdd 100644 --- a/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift +++ b/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift @@ -112,6 +112,7 @@ private extension Collection where Element == String { static var pathsRedirect: [String] {[ + "/archives/SomeArchive/", "/archives/SomeArchive/documentation", "/archives/SomeArchive/documentation/", "/archives/SomeArchive/tutorials/", @@ -142,6 +143,7 @@ private extension Collection where Element == String { ]} static var urisRedirect: [String] {[ + "/archives/SomeArchive", "/archives/SomeArchive/", "/archives/SomeArchive/documentation", "/archives/SomeArchive/tutorials",