Skip to content

Commit

Permalink
feat(canyon-data): add parseProjectID function
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Dec 30, 2024
1 parent 70fc7cf commit b76c29d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/canyon-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canyon-data",
"version": "2.0.0-beta.12",
"version": "2.0.0-beta.15",
"description": "",
"type": "module",
"exports": {
Expand Down
11 changes: 11 additions & 0 deletions packages/canyon-data/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ export function percent(covered:number, total:number) {
return 100.0;
}
}

export function parseProjectID(projectID:string) {
if (projectID.split("-").length !== 3) {
throw new Error(`Invalid projectID: ${projectID}`);
}
return {
provider: projectID.split("-")[0],
repoID: projectID.split("-")[1],
slug: projectID.split("-")[2],
}
}

0 comments on commit b76c29d

Please sign in to comment.