Skip to content

Commit

Permalink
chore: refactor contribute script (#5985)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed Jul 4, 2024
1 parent 8160df7 commit aa51954
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/contribute.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ function checkStagingArea() {
}

function parseGithubUrl(url) {
const regex = /https:\/\/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)/;
const regex = /https:\/\/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)(\/(.+))*/;
const match = url.match(regex);
if (!match) {
throw new Error('无法解析 GitHub URL');
}
return { username: match[1], repository: match[2], branch: match[3] + '/' + match[4] };
const [, username, repository, ...branch] = match;
return { username, repository, branch: branch.filter(Boolean).join('/') };
}

function addRemoteAndCheckoutBranch(username, branch) {
Expand Down

0 comments on commit aa51954

Please sign in to comment.