diff --git a/src/main/kotlin/com/github/kawamataryo/copygitlink/utils/utils.kt b/src/main/kotlin/com/github/kawamataryo/copygitlink/utils/utils.kt index ffdf684..b479b8a 100644 --- a/src/main/kotlin/com/github/kawamataryo/copygitlink/utils/utils.kt +++ b/src/main/kotlin/com/github/kawamataryo/copygitlink/utils/utils.kt @@ -38,8 +38,8 @@ fun getRepositoryPathFromRemoteUrl( remoteUrl: String, ): String { val result = - Regex(".*(?:@|\\/\\/)(.[^:\\/]*)(?::[0-9]{1,4})?.([^\\.]+)(\\.git)?\$").matchEntire( + Regex(".*(?:@|//)(.[^:/]*)(:?:[0-9]{1,4})?.([^.]+)(\\.git)?\$").matchEntire( remoteUrl ) - return result?.groupValues?.get(1) + "/" + result?.groupValues?.get(2) ?: "" + return result?.groupValues?.get(1) + result?.groupValues?.get(2) + "/" + result?.groupValues?.get(3) ?: "" } diff --git a/src/test/kotlin/com/github/kawamataryo/copygitlink/utils/utilsTest.kt.kt b/src/test/kotlin/com/github/kawamataryo/copygitlink/utils/utilsTest.kt.kt index 0605b91..627ed82 100644 --- a/src/test/kotlin/com/github/kawamataryo/copygitlink/utils/utilsTest.kt.kt +++ b/src/test/kotlin/com/github/kawamataryo/copygitlink/utils/utilsTest.kt.kt @@ -18,6 +18,7 @@ class UtilsKtTest { "ssh://git@github.com:user/repo.git, github.com/user/repo", "git://github.com/user/repo.git, github.com/user/repo", "https://github.com/YandexClassifieds/projectname, github.com/YandexClassifieds/projectname", + "https://gitlab.self-hosted.com:8443/projgroup/projectname, gitlab.self-hosted.com:8443/projgroup/projectname", ) fun testGetRepositoryPathFromRemoteUrl(remoteUrl: String, expectedPath: String) { val actualPath = getRepositoryPathFromRemoteUrl(remoteUrl)