MCPcopy
hub / github.com/upstash/context7 / assertSkillNameInRoot

Function assertSkillNameInRoot

packages/cli/src/utils/skill-name.ts:14–24  ·  view source on GitHub ↗
(skillsRoot: string, skillName: string)

Source from the content-addressed store, hash-verified

12}
13
14export function assertSkillNameInRoot(skillsRoot: string, skillName: string): string {
15 if (!isSafeSkillName(skillName)) {
16 throw new Error(`Unsafe skill name: ${JSON.stringify(skillName)}`);
17 }
18 const root = resolve(skillsRoot);
19 const target = resolve(root, skillName);
20 if (dirname(target) !== root || basename(target) !== skillName) {
21 throw new Error(`Skill name "${skillName}" escapes the skills root`);
22 }
23 return target;
24}

Callers 4

installSkillFilesFunction · 0.85
symlinkSkillFunction · 0.85
removeCommandFunction · 0.85
installer.test.tsFile · 0.85

Calls 1

isSafeSkillNameFunction · 0.85

Tested by

no test coverage detected