MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getVersionFromPath

Function getVersionFromPath

src/utils/plugins/pluginVersioning.ts:127–147  ·  view source on GitHub ↗
(installPath: string)

Source from the content-addressed store, hash-verified

125 * @returns Version string from path, or null if not a versioned path
126 */
127export function getVersionFromPath(installPath: string): string | null {
128 // Versioned paths have format: .../plugins/cache/marketplace/plugin/version/
129 const parts = installPath.split('/').filter(Boolean)
130
131 // Find 'cache' index to determine depth
132 const cacheIndex = parts.findIndex(
133 (part, i) => part === 'cache' && parts[i - 1] === 'plugins',
134 )
135
136 if (cacheIndex === -1) {
137 return null
138 }
139
140 // Versioned path has 3 components after 'cache': marketplace/plugin/version
141 const componentsAfterCache = parts.slice(cacheIndex + 1)
142 if (componentsAfterCache.length >= 3) {
143 return componentsAfterCache[2] || null
144 }
145
146 return null
147}
148
149/**
150 * Check if a path is a versioned plugin path.

Callers 1

isVersionedPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected