MCPcopy
hub / github.com/ZToolsCenter/ZTools / normalizeIconPath

Function normalizeIconPath

src/main/common/iconUtils.ts:10–29  ·  view source on GitHub ↗
(iconPath: string, basePath: string)

Source from the content-addressed store, hash-verified

8 * @returns 标准化后的图标路径
9 */
10export function normalizeIconPath(iconPath: string, basePath: string): string {
11 // 如果是 base64,直接返回
12 if (iconPath.startsWith('data:')) {
13 return iconPath
14 }
15
16 // 如果是 http/https,直接返回
17 if (iconPath.startsWith('http://') || iconPath.startsWith('https://')) {
18 return iconPath
19 }
20
21 // 如果已经是 file:// 协议,直接返回
22 if (iconPath.startsWith('file:///')) {
23 return iconPath
24 }
25
26 // 否则认为是相对路径,转换为绝对路径
27 const absolutePath = path.join(basePath, iconPath)
28 return pathToFileURL(absolutePath).href
29}

Callers 2

addToHistoryMethod · 0.90
getAllPluginsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected