MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / resolveRemoteFile

Function resolveRemoteFile

frontend/app/element/markdown-util.ts:157–173  ·  view source on GitHub ↗
(filepath: string, resolveOpts: MarkdownResolveOpts)

Source from the content-addressed store, hash-verified

155}
156
157export const resolveRemoteFile = async (filepath: string, resolveOpts: MarkdownResolveOpts): Promise<string | null> => {
158 if (!filepath || filepath.startsWith("http://") || filepath.startsWith("https://")) {
159 return filepath;
160 }
161 try {
162 const baseDirUri = formatRemoteUri(resolveOpts.baseDir, resolveOpts.connName);
163 const fileInfo = await RpcApi.FileJoinCommand(TabRpcClient, [baseDirUri, filepath]);
164 const remoteUri = formatRemoteUri(fileInfo.path, resolveOpts.connName);
165 // console.log("markdown resolve", resolveOpts, filepath, "=>", baseDirUri, remoteUri);
166 const usp = new URLSearchParams();
167 usp.set("path", remoteUri);
168 return getWebServerEndpoint() + "/wave/stream-file?" + usp.toString();
169 } catch (err) {
170 console.warn("Failed to resolve remote file:", filepath, err);
171 return null;
172 }
173};
174
175export const resolveSrcSet = async (srcSet: string, resolveOpts: MarkdownResolveOpts): Promise<string> => {
176 if (!srcSet) return null;

Callers 2

resolveFnFunction · 0.90
resolveSrcSetFunction · 0.85

Calls 3

formatRemoteUriFunction · 0.90
setMethod · 0.80
FileJoinCommandMethod · 0.65

Tested by

no test coverage detected