Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 09:54:24 +01:00

Linter fix: Rename UrlPrefix => URLPrefix

This commit is contained in:
Nirmal Kumar R 2024-11-04 23:56:35 +00:00
parent 4e700f5727
commit 27d05b69b5
3 changed files with 10 additions and 10 deletions

View file

@ -44,7 +44,7 @@ func Markup(ctx *context.APIContext) {
re := common.Renderer{ re := common.Renderer{
Mode: form.Mode, Mode: form.Mode,
Text: form.Text, Text: form.Text,
UrlPrefix: form.Context, URLPrefix: form.Context,
FilePath: form.FilePath, FilePath: form.FilePath,
BranchPath: form.BranchPath, BranchPath: form.BranchPath,
RelativePath: form.RelativePath, RelativePath: form.RelativePath,
@ -89,7 +89,7 @@ func Markdown(ctx *context.APIContext) {
re := common.Renderer{ re := common.Renderer{
Mode: mode, Mode: mode,
Text: form.Text, Text: form.Text,
UrlPrefix: form.Context, URLPrefix: form.Context,
IsWiki: form.Wiki, IsWiki: form.Wiki,
} }

View file

@ -19,7 +19,7 @@ import (
) )
type Renderer struct { type Renderer struct {
Mode, Text, UrlPrefix, FilePath, BranchPath, RelativePath string Mode, Text, URLPrefix, FilePath, BranchPath, RelativePath string
IsWiki bool IsWiki bool
} }
@ -40,7 +40,7 @@ func (re *Renderer) RenderMarkup(ctx *context.Base, repo *context.Repository) {
Ctx: ctx, Ctx: ctx,
Links: markup.Links{ Links: markup.Links{
AbsolutePrefix: true, AbsolutePrefix: true,
Base: re.UrlPrefix, Base: re.URLPrefix,
}, },
}, strings.NewReader(re.Text), ctx.Resp); err != nil { }, strings.NewReader(re.Text), ctx.Resp); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error()) ctx.Error(http.StatusInternalServerError, err.Error())
@ -55,19 +55,19 @@ func (re *Renderer) RenderMarkup(ctx *context.Base, repo *context.Repository) {
case "file": case "file":
// File as document based on file extension // File as document based on file extension
markupType = "" markupType = ""
re.UrlPrefix = re.RelativePath re.URLPrefix = re.RelativePath
relativePath = re.FilePath relativePath = re.FilePath
default: default:
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", re.Mode)) ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", re.Mode))
return return
} }
if !strings.HasPrefix(setting.AppSubURL+"/", re.UrlPrefix) { if !strings.HasPrefix(setting.AppSubURL+"/", re.URLPrefix) {
// check if urlPrefix is already set to a URL // check if urlPrefix is already set to a URL
linkRegex, _ := xurls.StrictMatchingScheme("https?://") linkRegex, _ := xurls.StrictMatchingScheme("https?://")
m := linkRegex.FindStringIndex(re.UrlPrefix) m := linkRegex.FindStringIndex(re.URLPrefix)
if m == nil { if m == nil {
re.UrlPrefix = util.URLJoin(setting.AppURL, re.UrlPrefix) re.URLPrefix = util.URLJoin(setting.AppURL, re.URLPrefix)
} }
} }
@ -87,7 +87,7 @@ func (re *Renderer) RenderMarkup(ctx *context.Base, repo *context.Repository) {
Ctx: ctx, Ctx: ctx,
Links: markup.Links{ Links: markup.Links{
AbsolutePrefix: true, AbsolutePrefix: true,
Base: re.UrlPrefix, Base: re.URLPrefix,
BranchPath: re.BranchPath, BranchPath: re.BranchPath,
}, },
Metas: meta, Metas: meta,

View file

@ -18,7 +18,7 @@ func Markup(ctx *context.Context) {
re := common.Renderer{ re := common.Renderer{
Mode: form.Mode, Mode: form.Mode,
Text: form.Text, Text: form.Text,
UrlPrefix: form.Context, URLPrefix: form.Context,
FilePath: form.FilePath, FilePath: form.FilePath,
BranchPath: form.BranchPath, BranchPath: form.BranchPath,
RelativePath: form.RelativePath, RelativePath: form.RelativePath,