diff --git a/Sources/DocCMiddleware/Internal/Extensions/String+Constants.swift b/Sources/DocCMiddleware/Internal/Extensions/String+Constants.swift index 267dab8..d807c5c 100644 --- a/Sources/DocCMiddleware/Internal/Extensions/String+Constants.swift +++ b/Sources/DocCMiddleware/Internal/Extensions/String+Constants.swift @@ -13,8 +13,18 @@ extension String { /// An empty string. static let empty = "" - /// A forwarding slash. - static let forwardSlash = "/" - /// An indication of a previous folder in a path component. - static let previousFolder = ".." + + /// A namespace that defines logging representations. + enum Logging { + /// A name of the middleware that triggered a logging event. + static let source = "DocCMiddleware" + } + + /// A namespace that defines relative path representations. + enum Path { + /// A forwarding slash. + static let forwardSlash = "/" + /// An indication of a previous folder in a path component. + static let previousFolder = ".." + } } diff --git a/Sources/DocCMiddleware/Internal/Use Cases/CheckURIUseCase.swift b/Sources/DocCMiddleware/Internal/Use Cases/CheckURIUseCase.swift index ad6b9fb..81ddf5e 100644 --- a/Sources/DocCMiddleware/Internal/Use Cases/CheckURIUseCase.swift +++ b/Sources/DocCMiddleware/Internal/Use Cases/CheckURIUseCase.swift @@ -23,8 +23,8 @@ struct CheckURIUseCase { func callAsFunction(_ uri: URI) -> String? { guard let uriPath = uri.path.removingPercentEncoding, - !uriPath.contains(.previousFolder), - uriPath.hasPrefix(.forwardSlash) + !uriPath.contains(.Path.previousFolder), + uriPath.hasPrefix(.Path.forwardSlash) else { return nil } diff --git a/Sources/DocCMiddleware/Internal/Use Cases/PrepareURIPathUseCase.swift b/Sources/DocCMiddleware/Internal/Use Cases/PrepareURIPathUseCase.swift index e0bce51..493df4a 100644 --- a/Sources/DocCMiddleware/Internal/Use Cases/PrepareURIPathUseCase.swift +++ b/Sources/DocCMiddleware/Internal/Use Cases/PrepareURIPathUseCase.swift @@ -56,7 +56,7 @@ struct PrepareURIPathUseCase { } let documentationName = uriRest - .split(separator: .forwardSlash) + .split(separator: .Path.forwardSlash) .map(String.init) .first @@ -110,9 +110,9 @@ private extension PrepareURIPathUseCase { return nil } guard let uriRest = matches.output.1 else { - return .forwardSlash + return .Path.forwardSlash } - guard uriRest.hasPrefix(String.forwardSlash) else { + guard uriRest.hasPrefix(.Path.forwardSlash) else { return .init(format: .Format.Path.root, uriRest) } return uriRest diff --git a/Sources/DocCMiddleware/Internal/Use Cases/RedirectURIUseCase.swift b/Sources/DocCMiddleware/Internal/Use Cases/RedirectURIUseCase.swift index ef6efa9..8b226a1 100644 --- a/Sources/DocCMiddleware/Internal/Use Cases/RedirectURIUseCase.swift +++ b/Sources/DocCMiddleware/Internal/Use Cases/RedirectURIUseCase.swift @@ -50,7 +50,7 @@ struct RedirectURIUseCase { statusCode: .movedPermanently, redirect: uriPath ), - source: .source + source: .Logging.source ) } @@ -61,10 +61,3 @@ struct RedirectURIUseCase { } } - -// MARK: - String+Constants - -private extension String { - /// A name of the middleware that triggered a logging event. - static let source = "DocCMiddleware" -} diff --git a/Tests/DocCMiddleware/Tests/Internal/Use Cases/PrepareURIPathUseCaseTests.swift b/Tests/DocCMiddleware/Tests/Internal/Use Cases/PrepareURIPathUseCaseTests.swift index 8dfde44..465af8b 100644 --- a/Tests/DocCMiddleware/Tests/Internal/Use Cases/PrepareURIPathUseCaseTests.swift +++ b/Tests/DocCMiddleware/Tests/Internal/Use Cases/PrepareURIPathUseCaseTests.swift @@ -135,7 +135,7 @@ private extension Output { /// A list of expected outputs for the URI path samples, regardless their match against suffixed or not suffixed root URI paths. static let prepareURIPaths: [PrepareURIPathUseCase.PreparedURIPaths?] = [ ("somearchive", "/SomeArchive.doccarchive", "/SomeArchive/some/content/path"), - (.empty, .empty, .forwardSlash), + (.empty, .empty, .Path.forwardSlash), nil ] }