Fix trailing slash on uploads URL
This commit is contained in:
parent
90e315a7a8
commit
24766fcf56
6 changed files with 19 additions and 6 deletions
|
|
@ -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"),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue