Repository navigation
MarkdownAura v1.1.0
MarkdownAura 1.1.0
A document's images load now. Every  in every document was a broken icon. The
renderer wrote the author's destination into the page exactly as typed, and a webview resolves a relative
src against its own origin — http://127.0.0.1:1420 in development, tauri://localhost in the
installer — never against the folder the document came from. Rendering now resolves each destination
against the document's own folder and hands the webview an asset-protocol URL, the one origin the page's
CSP lets an image through. Percent-encoding is decoded, so a%20b.png finds the file named a b.png;
. and .. are resolved before the URL exists, because the protocol refuses any path that still holds a
..; a data: URI and a remote URL are left exactly as written, since the CSP is what decides about
those.
The folder a document lives in is readable, however you reached it. The asset protocol is enabled
with an empty scope and serves only what is added to it, and only open_folder ever added anything — so
a document opened from Open markdown, the recent list, or Open with pointed its images at a folder the
protocol refused, even once the rewrite existed. Opening a folder, resolving a path from the shell, and
rendering a document (including the live preview beside the editor) all widen the scope to that folder
now. The rewrite itself is a parameter of the renderer rather than a policy buried in it: a caller with no
file behind the text gets its destinations left alone.
MarkdownAura 1.1.0
文档里的图片现在真的能显示了。 之前每一篇文档里的  都是碎图标。渲染器把作者写下的目标路径原样写进页面,而 webview 解析相对 src 用的是它自己的 origin——开发时是 http://127.0.0.1:1420,安装版是 tauri://localhost——从来不是文档所在的目录。现在渲染时会把每个目标路径按文档自身目录解析,再交给 webview 一个 asset 协议 URL,那是页面 CSP 唯一允许图片通过的来源。百分号编码会被解码(a%20b.png 找到的就是名为 a b.png 的文件);. 和 .. 在 URL 生成之前就消解掉,因为协议拒绝任何还带着 .. 的路径;data: URI 和远程地址原样保留——那些归 CSP 管。
文档所在目录一定可读,不管你是从哪儿打开它的。 asset 协议是开着、但 scope 为空,只服务被加进去的目录,而以前只有 open_folder 会往里加——于是从「打开 Markdown」对话框、最近列表或「打开方式」进来的文档,即使路径改写好了,图片指向的目录也照样被协议拒绝。现在打开文件夹、从命令行解析路径、渲染文档(包括编辑器旁边的实时预览)都会把该目录放行。路径改写本身也变成了渲染器的一个参数,而不是埋在渲染里的策略:文字背后没有文件的调用方,目标路径保持原样。