Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28a38d7

Browse files
author
Aly Sewelam
committed
Resolve linting issues
Modernise string suffix check with CutSuffixAdded nilcheck for entry after the org version check attempt
1 parent83353a8 commit28a38d7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎routers/web/repo/wiki.go‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ func wikiEntryByName(ctx *context.Context, commit *git.Commit, wikiName wiki_ser
154154
}
155155
ifentry==nil {
156156
// If .md file not found, try .org file
157-
ifstrings.HasSuffix(gitFilename,".md") {
158-
orgFilename:=strings.TrimSuffix(gitFilename,".md")+".org"
157+
ifbase,ok:=strings.CutSuffix(gitFilename,".md");ok {
158+
orgFilename:=base+".org"
159159
entry,err=findEntryForFile(commit,orgFilename)
160160
iferr!=nil&&!git.IsErrNotExist(err) {
161161
ctx.ServerError("findEntryForFile",err)
@@ -168,10 +168,10 @@ func wikiEntryByName(ctx *context.Context, commit *git.Commit, wikiName wiki_ser
168168
// If still not found, check if the file without extension exists (for raw files)
169169
ifentry==nil {
170170
baseFilename:=gitFilename
171-
ifstrings.HasSuffix(baseFilename,".md") {
172-
baseFilename=strings.TrimSuffix(baseFilename,".md")
173-
}elseifstrings.HasSuffix(baseFilename,".org") {
174-
baseFilename=strings.TrimSuffix(baseFilename,".org")
171+
ifbase,ok:=strings.CutSuffix(baseFilename,".md");ok {
172+
baseFilename=base
173+
}elseifbase,ok:=strings.CutSuffix(baseFilename,".org");ok {
174+
baseFilename=base
175175
}
176176
entry,err=findEntryForFile(commit,baseFilename)
177177
iferr!=nil&&!git.IsErrNotExist(err) {
@@ -678,10 +678,12 @@ func WikiRaw(ctx *context.Context) {
678678
ctx.ServerError("findFile",err)
679679
return
680680
}
681-
entry,err=findEntryForFile(commit,providedGitPath)
682-
iferr!=nil&&!git.IsErrNotExist(err) {
683-
ctx.ServerError("findFile",err)
684-
return
681+
ifentry==nil {
682+
entry,err=findEntryForFile(commit,providedGitPath)
683+
iferr!=nil&&!git.IsErrNotExist(err) {
684+
ctx.ServerError("findFile",err)
685+
return
686+
}
685687
}
686688
}
687689
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp