fix wiki normalizeName

This commit is contained in:
hang 2022-04-27 11:06:03 +08:00
parent 2115033586
commit c0d676e560
1 changed files with 8 additions and 8 deletions

View File

@ -6,17 +6,18 @@
package wiki
import (
"errors"
"fmt"
"net/url"
"os"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/sync"
"code.gitea.io/gitea/modules/util"
"errors"
"fmt"
"net/url"
"os"
"strings"
)
var (
@ -40,7 +41,7 @@ func NameToSubURL(name string) string {
// NormalizeWikiName normalizes a wiki name
func NormalizeWikiName(name string) string {
return strings.ReplaceAll(name, "-", " ")
return strings.ReplaceAll(name, "-", "-")
}
// NameToFilename converts a wiki name to its corresponding filename.
@ -80,7 +81,6 @@ func InitWiki(repo *models.Repository) error {
if repo.HasWiki() {
return nil
}
if err := git.InitRepository(repo.WikiPath(), true); err != nil {
return fmt.Errorf("InitRepository: %v", err)
} else if err = repo_module.CreateDelegateHooks(repo.WikiPath()); err != nil {
@ -206,7 +206,7 @@ func updateWikiPage(doer *models.User, repo *models.Repository, oldWikiName, new
}
// FIXME: The wiki doesn't have lfs support at present - if this changes need to check attributes here
// content = strings.Replace(content, "<br/>", "\n", -1)
objectHash, err := gitRepo.HashObject(strings.NewReader(content))
if err != nil {
log.Error("%v", err)