Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP git remotes are not correctly parsed, breaking HTML links #13

Closed
SimonMarquis opened this issue Jul 1, 2024 · 2 comments
Closed

Comments

@SimonMarquis
Copy link

SimonMarquis commented Jul 1, 2024

This weirdly written function (looks like an automated translation from another language) does not correctly parse HTTP git remotes:

fun remoteRepoGitUrlToHttps(remoteGitRepoUrl: String): String {
return listOf(remoteGitRepoUrl).map {
if (it.contains("@")) {
it.split("@")[1]
} else {
it
}
}.map {
val gitExtension = ".git"
if (it.endsWith(gitExtension)) {
it.substring(0, it.length - gitExtension.length)
} else {
it
}
}.map {
buildString {
append("https://")
append(it.replace(":", "/"))
}
}[0]
}

For instance,

❯ git remote get-url origin
https://github.com/foo/bar.git

will lead to this function returning https://https///github.com/foo/bar, which then is written like this in the header (and also used in multiple other places like git branch, git commit, etc.):

<a href="https://https///github.com/foo/bar" target="_blank">//github.com/foo/bar</a>

Let me know if you accept PRs at this stage of the project :)

@SimonMarquis SimonMarquis changed the title HTTP git remotes are not correctly parsed, breaking header & jumbotron links HTTP git remotes are not correctly parsed, breaking HTML links Jul 1, 2024
@handstandsam
Copy link
Collaborator

I just fixed this (and wrote my first test for that part of the codebase!) 6c17f45

Great minds think alike!

It should be in the latest snapshot of 0.0.2-dev00-SNAPSHOT. Sorry about the long version names. Trying to start publish more, but trying to convey that it's very much a work in progress.

I'm closing this as it's "fixed". Let me know if you have any more issues and I can re-open.

@handstandsam
Copy link
Collaborator

handstandsam commented Jul 3, 2024

@SimonMarquis I verified this morning that the fix worked on the repo I'm using with https!

Note: I have it linking to an exact commit now instead of a branch. I think that's more accurate, but it's debatable about user experience. I created #16 to capture discussion on that topic if you have any input. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants