(filepath: string, resolveOpts: MarkdownResolveOpts)
| 155 | } |
| 156 | |
| 157 | export 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 | |
| 175 | export const resolveSrcSet = async (srcSet: string, resolveOpts: MarkdownResolveOpts): Promise<string> => { |
| 176 | if (!srcSet) return null; |
no test coverage detected