mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-01-28 01:08:34 +08:00
Fix markdown not supporting absolute resource paths
Enhanced the logic for resolving image and file paths in MarkdownPanel to better handle both absolute and relative paths, ensuring compatibility with Windows path formats and improving file existence checks.
This commit is contained in:
@@ -124,7 +124,19 @@ public class MarkdownPanel : WebpagePanel
|
||||
}
|
||||
else
|
||||
{
|
||||
var localPath = _fallbackPath + Uri.UnescapeDataString(requestedUri.AbsolutePath).Replace('/', '\\');
|
||||
// URL path is encoded, e.g. "%20" for spaces.
|
||||
var unescapedAbsolutePath = Uri.UnescapeDataString(requestedUri.AbsolutePath);
|
||||
|
||||
// Convert URL path to Windows path format (e.g. "/C:/Users/..." -> "C:\Users\...")
|
||||
var potentialAbsolutePath = unescapedAbsolutePath.TrimStart('/').Replace('/', '\\');
|
||||
|
||||
string localPath;
|
||||
// Check if it is an absolute path (e.g. )
|
||||
if (Path.IsPathRooted(potentialAbsolutePath) && File.Exists(potentialAbsolutePath))
|
||||
localPath = potentialAbsolutePath;
|
||||
else
|
||||
// Treat as relative path (e.g. )
|
||||
localPath = _fallbackPath + unescapedAbsolutePath.Replace('/', '\\');
|
||||
|
||||
if (File.Exists(localPath))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user