MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveRelTarget

Function resolveRelTarget

apps/sim/lib/pptx-renderer/parser/rel-parser.ts:60–81  ·  view source on GitHub ↗
(basePath: string, target: string)

Source from the content-addressed store, hash-verified

58 * → 'ppt/slides/slide1.xml'
59 */
60export function resolveRelTarget(basePath: string, target: string): string {
61 // Absolute targets (start with /) are returned as-is (strip leading /)
62 if (target.startsWith('/')) {
63 return target.slice(1)
64 }
65
66 // Split the base path into segments
67 const baseParts = basePath.replace(/\\/g, '/').split('/').filter(Boolean)
68 const targetParts = target.replace(/\\/g, '/').split('/').filter(Boolean)
69
70 // Walk through target parts, resolving '..' by popping base parts
71 const resolved = [...baseParts]
72 for (const part of targetParts) {
73 if (part === '..') {
74 resolved.pop()
75 } else if (part !== '.') {
76 resolved.push(part)
77 }
78 }
79
80 return resolved.join('/')
81}

Callers 3

parseDiagramFrameFunction · 0.90
buildPresentationFunction · 0.90
parseChartNodeFunction · 0.90

Calls 3

joinMethod · 0.80
replaceMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected