MCPcopy Index your code
hub / github.com/callstack/agent-device / parseRepositorySlug

Function parseRepositorySlug

src/utils/install-source-config.ts:71–88  ·  view source on GitHub ↗
(value: string, sourceLabel: string)

Source from the content-addressed store, hash-verified

69}
70
71function parseRepositorySlug(value: string, sourceLabel: string): { owner: string; repo: string } {
72 const separator = value.indexOf('/');
73 if (
74 separator <= 0 ||
75 separator === value.length - 1 ||
76 value.indexOf('/', separator + 1) !== -1
77 ) {
78 throw new AppError('INVALID_ARGS', `${sourceLabel} must use owner/repo.`);
79 }
80 const result = {
81 owner: value.slice(0, separator).trim(),
82 repo: value.slice(separator + 1).trim(),
83 };
84 if (!result.owner || !result.repo) {
85 throw new AppError('INVALID_ARGS', `${sourceLabel} must use owner/repo.`);
86 }
87 return result;
88}
89
90function readText(value: unknown): string | undefined {
91 return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;

Calls

no outgoing calls

Tested by

no test coverage detected