Implemented (a first version of) the DocCMiddleware middleware in the library target.

This commit is contained in:
2025-02-25 01:55:49 +01:00
parent 54aa5c70c6
commit 19a54b25ae
6 changed files with 254 additions and 0 deletions
@@ -0,0 +1,41 @@
enum Path {
// MARK: Functions
static func archiveName(from path: String) -> String {
let pathComponents = path.split(separator: .forwardSlash)
return pathComponents.count > 1
? String(pathComponents[1]).lowercased()
: .empty
}
static func resourcePath(from path: String) -> String {
let matches = path.matches(of: /\//)
return matches.count > 2
? .init(path[matches[2].startIndex...])
: .forwardSlash
}
}
// MARK: - String+Constants
extension String {
static let empty = ""
static let forwardSlash = "/"
static let previousFolder = ".."
}
// MARK: - Character+Constants
private extension Character {
static let forwardSlash: Character = "/"
}
// MARK: - String+Formats
private extension String.Format {
static let archiveDocC = "%@.doccarchive"
}