fix(msteams): detect windows local paths for uploads

This commit is contained in:
Peter Steinberger
2026-02-13 15:07:27 +00:00
parent c60780ba20
commit a5faea614b
2 changed files with 24 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;
}
/**