MCPcopy Create free account
hub / github.com/Snapchat/Valdi / fromString

Method fromString

npm_modules/cli/src/utils/BazelClient.ts:51–74  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

49 ) {}
50
51 static fromString(str: string): BazelLabel {
52 let repo: string | undefined;
53 if (str.startsWith('@')) {
54 const slashSlashIndex = str.indexOf('//');
55 if (slashSlashIndex <= 0) {
56 throw new Error(`Expected // after repo name (got ${str})`);
57 }
58
59 repo = str.slice(1, slashSlashIndex);
60 str = str.slice(slashSlashIndex);
61 }
62 if (str.endsWith('/')) {
63 str = str.slice(0, -1);
64 }
65
66 const separatorIndex = str.indexOf(':');
67 if (separatorIndex >= 0) {
68 const target = str.slice(0, separatorIndex);
69 const name = str.slice(separatorIndex + 1);
70 return new BazelLabel(repo, target, name);
71 } else {
72 return new BazelLabel(repo, str, undefined);
73 }
74 }
75
76 get apparentRepo(): string | undefined {
77 if (!this.repo) return undefined;

Callers 3

resolveLabelMethod · 0.45
projectsync.tsFile · 0.45
parseProjectSyncJSONFunction · 0.45

Calls 2

startsWithMethod · 0.80
indexOfMethod · 0.45

Tested by

no test coverage detected