-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix Github Wiki Page Links #4538
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
a61492b
91eba25
f133fe4
4a0cf89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,6 +159,19 @@ func GenerateLink(repo, commit, file string, line int64) string { | |
| baseLink += "#L" + strconv.FormatInt(line, 10) | ||
| } | ||
| } | ||
| } else if strings.HasSuffix(repo, ".wiki.git") { | ||
| // GitHub Wiki links are formatted differently | ||
| baseLink = repo[:len(repo)-9] + "/wiki/" | ||
| if file != "" { | ||
| baseLink += strings.TrimSuffix(file, ".md") + "/" | ||
| } | ||
| if commit != "" { | ||
| baseLink += commit | ||
| } | ||
| if line > 0 { | ||
| baseLink += "#L" + strconv.FormatInt(line, 10) | ||
| } | ||
|
Comment on lines
+170
to
+175
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these are real possibilities, I think they should have test cases.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
|
|
||
|
||
| } else if file == "" { | ||
| baseLink = repo[:len(repo)-4] + "/commit/" + commit | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that if
fileis empty, the actual file we care about is a markdown file, right? That seems very specific. How do we know that?In any case, this seems like something that should be explained in a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this comment because my assumption was that wiki documents can only be created in markdown format, but it turns out github supports all of these:

Even though markdown is set by default and most wikis would be using markdown, best solution would be to just remove the file extension, whatever it is. I'll do that