Skip to content

Commit

Permalink
fix: normalize GitHub API URL (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher authored May 22, 2024
1 parent 2bc11bc commit 1e66974
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/octokit.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export const SemanticReleaseOctokit = Octokit.plugin(
export function toOctokitOptions(options) {
const baseUrl =
"githubApiUrl" in options && options.githubApiUrl
? options.githubApiUrl
? // Use `urljoin` to normalize the provided URL
urljoin(options.githubApiUrl, "")
: "githubUrl" in options && options.githubUrl
? urljoin(options.githubUrl, options.githubApiPathPrefix)
: undefined;
Expand Down
15 changes: 15 additions & 0 deletions test/to-octokit-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@ test("Do not use a proxy if set to false", async (t) => {
});
t.is(request.agent, undefined);
});

test("githubUrl with trailing slash", async (t) => {
const options = toOctokitOptions({
githubUrl: "http://localhost:10001/",
githubApiPathPrefix: "",
});
t.is(options.baseUrl, "http://localhost:10001");
});

test("githubApiUrl with trailing slash", async (t) => {
const options = toOctokitOptions({
githubApiUrl: "http://api.localhost:10001/",
});
t.is(options.baseUrl, "http://api.localhost:10001");
});

0 comments on commit 1e66974

Please sign in to comment.