mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
fix(msteams): detect windows local paths for uploads
This commit is contained in:
@@ -145,6 +145,15 @@ describe("msteams media-helpers", () => {
|
||||
expect(isLocalPath("~/Downloads/image.png")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for Windows absolute drive paths", () => {
|
||||
expect(isLocalPath("C:\\Users\\test\\image.png")).toBe(true);
|
||||
expect(isLocalPath("D:/data/photo.jpg")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for Windows UNC paths", () => {
|
||||
expect(isLocalPath("\\\\server\\share\\image.png")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for http URLs", () => {
|
||||
expect(isLocalPath("http://example.com/image.png")).toBe(false);
|
||||
expect(isLocalPath("https://example.com/image.png")).toBe(false);
|
||||
|
||||
@@ -65,7 +65,21 @@ export async function extractFilename(url: string): Promise<string> {
|
||||
* Check if a URL refers to a local file path.
|
||||
*/
|
||||
export function isLocalPath(url: string): boolean {
|
||||
return url.startsWith("file://") || url.startsWith("/") || url.startsWith("~");
|
||||
if (url.startsWith("file://") || url.startsWith("/") || url.startsWith("~")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Windows drive-letter absolute path (e.g. C:\foo\bar.txt or C:/foo/bar.txt)
|
||||
if (/^[a-zA-Z]:[\\/]/.test(url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Windows UNC path (e.g. \\server\share\file.txt)
|
||||
if (url.startsWith("\\\\")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user