Implemented (a first version of) the DocCMiddleware middleware in the library target.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user