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

Function parseSkillInput

packages/cli/src/utils/parse-input.ts:9–25  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

7}
8
9export function parseSkillInput(input: string): ParsedSkillInput | null {
10 const urlMatch = input.match(
11 /(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/]+)\/tree\/([^\/]+)\/(.+)/
12 );
13 if (urlMatch) {
14 const [, owner, repo, branch, path] = urlMatch;
15 return { type: "url", owner, repo, branch, path };
16 }
17
18 const shortMatch = input.match(/^\/?([^\/]+)\/([^\/]+)$/);
19 if (shortMatch) {
20 const [, owner, repo] = shortMatch;
21 return { type: "repo", owner, repo };
22 }
23
24 return null;
25}

Callers 2

installCommandFunction · 0.85
infoCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected