Skip to content

Commit c0754e9

Browse files
Gustedzeripath
Gusted
andauthored
Don't open new page for ext wiki on same repository (#20725) (#20910)
* Don't open new page for ext wiki on same repository (#20725) - Backport of #20725 - When the external wiki has been set to a file on the repository, don't open the page on a tab. - Resolves #20657 * Gofmt * Fix line Co-authored-by: zeripath <[email protected]>
1 parent bf41958 commit c0754e9

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/templates/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ func NewFuncMap() []template.FuncMap {
454454
}
455455
return items
456456
},
457+
"HasPrefix": strings.HasPrefix,
457458
}}
458459
}
459460

templates/repo/header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
{{end}}
207207

208208
{{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}}
209-
<a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if (.Permission.CanRead $.UnitTypeExternalWiki)}} target="_blank" rel="noopener noreferrer" {{end}}>
209+
<a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if and (.Permission.CanRead $.UnitTypeExternalWiki) (not (HasPrefix ((.Repository.MustGetUnit $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL) (.Repository.HTMLURL)))}} target="_blank" rel="noopener noreferrer" {{end}}>
210210
{{svg "octicon-book"}} {{.i18n.Tr "repo.wiki"}}
211211
</a>
212212
{{end}}

0 commit comments

Comments
 (0)