mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
test: improve test coverage; multiple internal refactors (#6912)
This commit is contained in:
parent
12a7305238
commit
ad88f5cc87
78 changed files with 1613 additions and 1149 deletions
|
@ -154,3 +154,40 @@ export function addTrailingSlash(str: string): string {
|
|||
export function removeTrailingSlash(str: string): string {
|
||||
return removeSuffix(str, '/');
|
||||
}
|
||||
|
||||
export function buildSshUrl(
|
||||
githubHost: string,
|
||||
organizationName: string,
|
||||
projectName: string,
|
||||
githubPort?: string,
|
||||
): string {
|
||||
if (githubPort) {
|
||||
return `ssh://git@${githubHost}:${githubPort}/${organizationName}/${projectName}.git`;
|
||||
}
|
||||
return `git@${githubHost}:${organizationName}/${projectName}.git`;
|
||||
}
|
||||
|
||||
export function buildHttpsUrl(
|
||||
gitCredentials: string,
|
||||
githubHost: string,
|
||||
organizationName: string,
|
||||
projectName: string,
|
||||
githubPort?: string,
|
||||
): string {
|
||||
if (githubPort) {
|
||||
return `https://${gitCredentials}@${githubHost}:${githubPort}/${organizationName}/${projectName}.git`;
|
||||
}
|
||||
return `https://${gitCredentials}@${githubHost}/${organizationName}/${projectName}.git`;
|
||||
}
|
||||
|
||||
export function hasSSHProtocol(sourceRepoUrl: string): boolean {
|
||||
try {
|
||||
if (new URL(sourceRepoUrl).protocol === 'ssh:') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch {
|
||||
// Fails when there isn't a protocol
|
||||
return /^(?:[\w-]+@)?[\w.-]+:[\w./-]+/.test(sourceRepoUrl); // git@github.com:facebook/docusaurus.git
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue