fix: add trailing .git to repositoryUrl only if it's present in the configured URL
This commit is contained in:
@@ -40,13 +40,11 @@ module.exports = async ({repositoryUrl, branch}) => {
|
||||
const gitCredentials = ['GL_TOKEN', 'GITLAB_TOKEN'].includes(envVar)
|
||||
? `gitlab-ci-token:${process.env[envVar]}`
|
||||
: process.env[envVar];
|
||||
const {protocols} = gitUrlParse(repositoryUrl);
|
||||
const {protocols, ...parsed} = gitUrlParse(repositoryUrl);
|
||||
const protocol = protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : 'https';
|
||||
|
||||
// If credentials are set via anvironment variables, convert the URL to http/https and add basic auth, otherwise return `repositoryUrl` as is
|
||||
return gitCredentials
|
||||
? format({...parse(`${gitUrlParse(repositoryUrl).toString(protocol)}.git`), ...{auth: gitCredentials}})
|
||||
: repositoryUrl;
|
||||
return gitCredentials ? {...parsed, ...{token: gitCredentials}}.toString(protocol) : repositoryUrl;
|
||||
}
|
||||
return repositoryUrl;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user