Allow relative paths in configuration file
This commit is contained in:
@ -50,4 +50,23 @@ extension URL {
|
||||
let attributes = try? FileManager.default.attributesOfItem(atPath: path)
|
||||
return (attributes?[.size] as? NSNumber)?.intValue
|
||||
}
|
||||
|
||||
func resolvingFolderTraversal() -> URL? {
|
||||
var components = [String]()
|
||||
absoluteString.components(separatedBy: "/").forEach { part in
|
||||
if part == ".." {
|
||||
if !components.isEmpty {
|
||||
_ = components.dropLast()
|
||||
} else {
|
||||
components.append("..")
|
||||
}
|
||||
return
|
||||
}
|
||||
if part == "." {
|
||||
return
|
||||
}
|
||||
components.append(part)
|
||||
}
|
||||
return URL(string: components.joined(separator: "/"))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user