fix: BitbucketServerURLParser should not fail if url contains spaces

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/601/head
Anatolii Bazko 2023-11-06 15:49:39 +01:00
parent 2c198333ef
commit bf3e493a83
1 changed files with 8 additions and 2 deletions

View File

@ -85,8 +85,14 @@ public class BitbucketServerURLParser {
}
private boolean isUserTokenPresent(String repositoryUrl) {
URI uri;
try {
uri = URI.create(repositoryUrl);
} catch (IllegalArgumentException e) {
return false;
}
String serverUrl = getServerUrl(repositoryUrl);
URI uri = URI.create(repositoryUrl);
String schema = uri.getScheme();
String host = uri.getHost();
if (bitbucketUrlPatternTemplates.stream()
@ -130,7 +136,7 @@ public class BitbucketServerURLParser {
// If the user request catches the unauthorised error, it means that the provided url
// belongs to Bitbucket.
bitbucketServerApiClient.getUser();
} catch (ScmItemNotFoundException | ScmCommunicationException e) {
} catch (ScmItemNotFoundException | ScmCommunicationException | IllegalArgumentException e) {
return false;
} catch (ScmUnauthorizedException e) {
return true;