fix(macos): avoid treating '/' as file target
This commit is contained in:
@@ -116,9 +116,13 @@ final class CanvasManager {
|
|||||||
if scheme == "https" || scheme == "http" || scheme == "file" { return url }
|
if scheme == "https" || scheme == "http" || scheme == "file" { return url }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convenience: existing absolute paths resolve as local files.
|
// Convenience: existing absolute *file* paths resolve as local files.
|
||||||
if trimmed.hasPrefix("/"), FileManager.default.fileExists(atPath: trimmed) {
|
// (Avoid treating Canvas routes like "/" as filesystem paths.)
|
||||||
return URL(fileURLWithPath: trimmed)
|
if trimmed.hasPrefix("/") {
|
||||||
|
var isDir: ObjCBool = false
|
||||||
|
if FileManager.default.fileExists(atPath: trimmed, isDirectory: &isDir), !isDir.boolValue {
|
||||||
|
return URL(fileURLWithPath: trimmed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -140,12 +140,16 @@ final class CanvasWindowController: NSWindowController, WKNavigationDelegate, NS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convenience: absolute paths resolve as local files when they exist.
|
// Convenience: absolute file paths resolve as local files when they exist.
|
||||||
if trimmed.hasPrefix("/"), FileManager.default.fileExists(atPath: trimmed) {
|
// (Avoid treating Canvas routes like "/" as filesystem paths.)
|
||||||
|
if trimmed.hasPrefix("/") {
|
||||||
|
var isDir: ObjCBool = false
|
||||||
|
if FileManager.default.fileExists(atPath: trimmed, isDirectory: &isDir), !isDir.boolValue {
|
||||||
let url = URL(fileURLWithPath: trimmed)
|
let url = URL(fileURLWithPath: trimmed)
|
||||||
canvasWindowLogger.debug("canvas load file \(url.absoluteString, privacy: .public)")
|
canvasWindowLogger.debug("canvas load file \(url.absoluteString, privacy: .public)")
|
||||||
self.loadFile(url)
|
self.loadFile(url)
|
||||||
return
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let url = CanvasScheme.makeURL(
|
guard let url = CanvasScheme.makeURL(
|
||||||
|
|||||||
Reference in New Issue
Block a user