Skip to content

Commit 27d7828

Browse files
committed
fix: handle undefined GitHub prefix
1 parent bc45bd0 commit 27d7828

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/resolve-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ const {castArray} = require('lodash');
33
module.exports = ({githubUrl, githubApiPathPrefix, assets}) => ({
44
githubToken: process.env.GH_TOKEN || process.env.GITHUB_TOKEN,
55
githubUrl: githubUrl || process.env.GH_URL || process.env.GITHUB_URL,
6-
githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX,
6+
githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX || '',
77
assets: assets ? castArray(assets) : assets,
88
});

test/verify.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test.serial('Verify package, token and repository access', async t => {
4444
t.true(github.isDone());
4545
});
4646

47-
test.serial('Verify package, token and repository access and custom URL', async t => {
47+
test.serial('Verify package, token and repository access and custom URL with prefix', async t => {
4848
const owner = 'test_user';
4949
const repo = 'test_repo';
5050
process.env.GH_TOKEN = 'github_token';
@@ -66,6 +66,23 @@ test.serial('Verify package, token and repository access and custom URL', async
6666
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication (%s)', 'https://othertesturl.com:9090/prefix']);
6767
});
6868

69+
test.serial('Verify package, token and repository access and custom URL without prefix', async t => {
70+
const owner = 'test_user';
71+
const repo = 'test_repo';
72+
process.env.GH_TOKEN = 'github_token';
73+
const githubUrl = 'https://othertesturl.com:9090';
74+
const github = authenticate({githubUrl})
75+
.get(`/repos/${owner}/${repo}`)
76+
.reply(200, {permissions: {push: true}});
77+
78+
await t.notThrows(
79+
verify({githubUrl}, {repositoryUrl: `git@othertesturl.com:${owner}/${repo}.git`}, t.context.logger)
80+
);
81+
82+
t.true(github.isDone());
83+
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication (%s)', 'https://othertesturl.com:9090']);
84+
});
85+
6986
test.serial('Verify package, token and repository with environment variables', async t => {
7087
const owner = 'test_user';
7188
const repo = 'test_repo';

0 commit comments

Comments
 (0)