Fixed an issue when routing empty "uriResource" inside the "handle(_: context: next: )" function for the DocCMiddleware middleware in the library target.

This commit is contained in:
Javier Cicchelli 2025-03-13 00:06:02 +01:00
parent a14d388321
commit 93bb6b2e4a
2 changed files with 7 additions and 1 deletions

View File

@ -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 {

View File

@ -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",