Update bitbucketServerPullRequest.ts - refactor parseProtocol to isApiBaseUrlHttps

refactor parseProtocol to isApiBaseUrlHttps; ie. instead of taking the protocol scheme from the URL object, use boolean  based on the apiBaseUrl to get whether to use "http" or "https". The default will still be "https".

Signed-off-by: Matthew Bednarski <matthewbednarski@gmail.com>
This commit is contained in:
Matthew Bednarski
2024-09-23 12:30:13 +02:00
committed by GitHub
parent f543632988
commit b1e5501b90
@@ -237,9 +237,9 @@ const getDefaultBranch = async (opts: {
}
return defaultBranch;
};
const parseProtocol = (apiBaseUrl: string) => {
const isApiBaseUrlHttps = (apiBaseUrl: string) : boolean => {
const url = new URL(apiBaseUrl);
return url.protocol || 'https';
return url.protocol === 'https:';
};
/**
* Creates a BitbucketServer Pull Request action.
@@ -405,8 +405,8 @@ export function createPublishBitbucketServerPullRequestAction(options: {
startPoint: latestCommit,
});
const protocol = parseProtocol(apiBaseUrl);
const remoteUrl = `${protocol}://${host}/scm/${project}/${repo}.git`;
const isHttps: boolean = isApiBaseUrlHttps(apiBaseUrl);
const remoteUrl = `${isHttps ? 'https' : 'http' }://${host}/scm/${project}/${repo}.git`;
const auth = authConfig.token
? {