Fixes path handling and adds remote image support

Addresses issues with path construction on Windows by using `path.isAbsolute()` to correctly handle absolute paths.  Improves cross-platform compatibility in temp directory management and binary location.

Adds support for downloading and embedding remote images (http/https URLs) in markdown, enhancing content integration. Provides fallback mechanism with placeholder text upon download failure.
This commit is contained in:
AlexKucera committed 2025-11-04 10:55:24 +01:00
1 parent 536351cbbf
commit 8329c9dd48
6 files changed
+263 -37

No files matched your search

+27 -2
View File
@@ -3,6 +3,7 @@
import { FileSystemAdapter, normalizePath, Notice } from 'obsidian';
import type { App, PluginManifest } from 'obsidian';
import * as path from 'path';
export class PathUtils {
constructor(private app: App) {}
@@ -28,12 +29,36 @@ export class PathUtils {
/**
* Join path segments with normalizePath
* Handles absolute paths correctly by using the last absolute path found
*/
joinPath(...segments: string[]): string {
// Filter out empty segments
const filtered = segments.filter(s => s);
const joined = filtered.join('/');
return normalizePath(joined);
if (filtered.length === 0) {
return '';
}
// Find the last absolute path in the segments
// If a segment is absolute, it becomes the new base and we ignore previous segments
let result = '';
for (const segment of filtered) {
if (path.isAbsolute(segment)) {
// This segment is absolute, use it as the new base
result = segment;
} else if (result) {
// Join with the current result
result = path.join(result, segment);
} else {
// First relative segment
result = segment;
}
}
// Normalize the final path using path.normalize for cross-platform compatibility
// then use Obsidian's normalizePath for vault-relative paths
const normalized = path.normalize(result);
return normalizePath(normalized);
}
/**