Open kkolyan opened 3 months ago
I'm also getting nulls in the URL, which in my case I think is related to having .
characters in the path before the .git
extension, as in this comment.
I looked a bit at the regex in https://github.com/kawamataryo/copy-git-link/blob/main/src/main/kotlin/com/github/kawamataryo/copygitlink/utils/utils.kt#L41 and it seems like you could simplify things by just grabbing everything after the host & port and then removing any .git
suffix from the path afterwards. So something like:
fun getRepositoryPathFromRemoteUrl(
remoteUrl: String,
): String {
val result =
Regex(".*(?:@|//)(.[^:/]*)(:?:[0-9]{1,4})?(.*)\$").matchEntire(
remoteUrl
)
val path = result?.groupValues?.get(3)?.removeSuffix(".git") ?: ""
return result?.groupValues?.get(1) + result?.groupValues?.get(2) + "/" + path
}
I don't have a kotlin environment set up on this machine, but if you like I could make a little PR to that effect this weekend.
Been having this null issue then realized there is built in support for this, at least PHPStorm. Highlight a line right-click, open in Github
In new IDEA version it generates URL with nulls instead of some critical URL parts: https://nullnull/null/blob/147b777baa25147742e85e1b9242051efe354e9f/GlipBot.postman_collection.json#L3