Skip to content

Commit

Permalink
url parsing based on codeql results
Browse files Browse the repository at this point in the history
  • Loading branch information
dacbd committed Oct 8, 2022
1 parent c83044e commit 9e52db4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ const inferToken = () => {
const inferDriver = (opts = {}) => {
const { repo } = opts;
if (repo) {
if (repo.includes('github.com')) return GITHUB;
if (repo.includes('gitlab.com')) return GITLAB;
if (/bitbucket\.(com|org)/.test(repo)) return BB;
const url = new URL(repo);
if (url.hostname === 'github.com') return GITHUB;
if (url.hostname === 'gitlab.com') return GITLAB;
if (/bitbucket\.(com|org)/.test(url.hostname)) return BB;
}

if (GITHUB_REPOSITORY) return GITHUB;
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ const octokit = (token, repo) => {
onAbuseLimit: throttleHandler
}
};

if (!repo.includes('github.com')) {
const { host, hostname } = new url.URL(repo);
if (hostname !== 'github.com') {
// GitHub Enterprise, use the: repo URL host + '/api/v3' - as baseURL
// as per: https://developer.github.com/enterprise/v3/enterprise-admin/#endpoint-urls
const { host } = new url.URL(repo);

octokitOptions.baseUrl = `https://${host}/api/v3`;
}

Expand Down

2 comments on commit 9e52db4

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.