MCPcopy Create free account
hub / github.com/Qinbf/groundmap / hrefToRef

Function hrefToRef

tools/debug-console/lib/wiki-ref.ts:140–155  ·  view source on GitHub ↗
(href: string)

Source from the content-addressed store, hash-verified

138}
139
140export function hrefToRef(href: string): WikiRef | null {
141 if (!href.startsWith("#kbref:")) return null;
142 try {
143 const json = decodeURIComponent(href.slice("#kbref:".length));
144 const obj = JSON.parse(json);
145 if (typeof obj !== "object" || !obj || typeof obj.path !== "string") return null;
146 return {
147 path: obj.path,
148 anchor: typeof obj.anchor === "string" ? obj.anchor : null,
149 isBlock: obj.isBlock === true,
150 alias: typeof obj.alias === "string" ? obj.alias : null,
151 };
152 } catch {
153 return null;
154 }
155}
156
157/**
158 * 把 markdown 文本里的 [[wiki/...]] 替换成标准 markdown 链接 `[text](#kbref:...)`,

Callers 2

aFunction · 0.90
aFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected