Skip to content

Commit

Permalink
Fix trailing slash on uploads URL
Browse files Browse the repository at this point in the history
  • Loading branch information
koesie10 committed May 13, 2024
1 parent 90e315a commit 24766fc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
8 changes: 7 additions & 1 deletion lib/database-upload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/database-upload.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/database-upload.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/database-upload.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/database-upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ test("Successfully uploading a database to GHEC-DR", async (t) => {
t.assert(
databaseUploadSpy.calledOnceWith(
sinon.match.string,
sinon.match.has("baseUrl", "https://uploads.tenant.ghe.com/"),
sinon.match.has("baseUrl", "https://uploads.tenant.ghe.com"),
),
);
});
Expand Down
9 changes: 8 additions & 1 deletion src/database-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export async function uploadDatabases(
const uploadsUrl = new URL(parseGitHubUrl(apiDetails.url));
uploadsUrl.hostname = `uploads.${uploadsUrl.hostname}`;

// Octokit expects the baseUrl to not have a trailing slash,
// but it is included by default in a URL.
let uploadsBaseUrl = uploadsUrl.toString();
if (uploadsBaseUrl.endsWith("/")) {
uploadsBaseUrl = uploadsBaseUrl.slice(0, -1);
}

for (const language of config.languages) {
try {
// Upload the database bundle.
Expand All @@ -57,7 +64,7 @@ export async function uploadDatabases(
await client.request(
`POST /repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name&commit_oid=:commit_oid`,
{
baseUrl: uploadsUrl.toString(),
baseUrl: uploadsBaseUrl,
owner: repositoryNwo.owner,
repo: repositoryNwo.repo,
language,
Expand Down

0 comments on commit 24766fc

Please sign in to comment.