Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Nov 17, 2024
1 parent f6b94fe commit 3595d30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ToCloneUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public static function fromRepoAndToken(string $repo, string $authToken) : strin

case 'www.bitbucket.org':
case 'bitbucket.org':
$repo_path = sprintf('https://x-token-auth:%[email protected]%s', $authToken, $repo_parsed["path"]);
$repo_path = sprintf(
'https://x-token-auth:%[email protected]%s',
$authToken,
$repo_parsed["path"]
);
if (strlen($authToken) < 50 && strpos($authToken, ':') !== false) {
$repo_path = sprintf(
'https://%[email protected]%s',
Expand Down
15 changes: 15 additions & 0 deletions tests/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ public static function provideAllCases() : array
'token123',
'https://oauth2:[email protected]/user/repo.git',
],
[
'https://bitbucket.org/user/repo.git',
'token123',
'https://x-token-auth:[email protected]/user/repo.git',
],
[
'https://www.bitbucket.org/user/repo.git',
'token123',
'https://x-token-auth:[email protected]/user/repo.git',
],
[
'https://www.bitbucket.org/user/repo.git',
'user:token123',
'https://user:[email protected]/user/repo.git',
],
];
}
}

0 comments on commit 3595d30

Please sign in to comment.