From 28002fb83534615f4b00a852ebdc8259d3eea6e2 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 12 Mar 2024 10:22:04 +0100 Subject: [PATCH] fix: Support BitBucket endpoint with path (#665) Signed-off-by: Anatolii Bazko --- .../factory/server/bitbucket/BitbucketServerURLParser.java | 2 +- .../server/bitbucket/BitbucketServerURLParserTest.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wsmaster/che-core-api-factory-bitbucket-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParser.java b/wsmaster/che-core-api-factory-bitbucket-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParser.java index 9ae765ad1f..f551cdce42 100644 --- a/wsmaster/che-core-api-factory-bitbucket-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParser.java +++ b/wsmaster/che-core-api-factory-bitbucket-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParser.java @@ -78,7 +78,7 @@ public BitbucketServerURLParser( bitbucketUrlPatternTemplates.forEach( t -> { String scheme = t.contains("git@") ? "ssh" : uri.getScheme(); - String host = uri.getHost(); + String host = uri.getHost() + uri.getPath(); bitbucketUrlPatterns.add(Pattern.compile(format(t, scheme, host))); }); } diff --git a/wsmaster/che-core-api-factory-bitbucket-server/src/test/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParserTest.java b/wsmaster/che-core-api-factory-bitbucket-server/src/test/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParserTest.java index 8cdd21ead6..c8598467fa 100644 --- a/wsmaster/che-core-api-factory-bitbucket-server/src/test/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParserTest.java +++ b/wsmaster/che-core-api-factory-bitbucket-server/src/test/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2023 Red Hat, Inc. + * Copyright (c) 2012-2024 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -59,7 +59,7 @@ public void prepare() { public void setUp() { bitbucketURLParser = new BitbucketServerURLParser( - "https://bitbucket.2mcl.com,https://bbkt.com", + "https://bitbucket.2mcl.com,https://bbkt.com,https://my-bitbucket.org/bitbucket", devfileFilenamesProvider, oAuthAPI, mock(PersonalAccessTokenManager.class)); @@ -145,6 +145,7 @@ public void shouldNotValidateUrlByApiRequest() { @DataProvider(name = "UrlsProvider") public Object[][] urls() { return new Object[][] { + {"https://my-bitbucket.org/bitbucket/scm/proj/repo.git"}, {"https://bitbucket.2mcl.com/scm/~user/repo.git"}, {"https://bitbucket.2mcl.com/scm/project/test1.git"}, {"https://bitbucket.2mcl.com/projects/project/repos/test1/browse?at=refs%2Fheads%2Fbranch"},