Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dee1b86e0 | |||
| 428ef27f7d | |||
| 85b1c4ba7c | |||
| 4d732e9b9c | |||
| ab24413dd8 | |||
| c38d8e4146 | |||
| a93a79c6a5 | |||
| 9c7753d566 | |||
| 55d348afba | |||
| d93cc81ff9 | |||
| 37d83a95f7 | |||
| 97f30335db | |||
| 28088362b6 | |||
| a14e5c9abb | |||
| 3a8bc0ee7a | |||
| 0cc7297f23 |
@@ -4,8 +4,6 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
auth_model "git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/auth"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/setting"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
|
||||
|
||||
@@ -150,18 +150,16 @@ func WebPathFromRequest(s string) WebPath {
|
||||
}
|
||||
|
||||
var multiHyphenRe = regexp.MustCompile(`-{2,}`)
|
||||
var nonSlugRe = regexp.MustCompile(`[^a-zA-Z0-9+.\-]`)
|
||||
var nonAlphanumRe = regexp.MustCompile(`[^a-zA-Z0-9\-]`)
|
||||
|
||||
// sanitizeWikiTitle converts a user-provided title into a clean, URL-friendly slug.
|
||||
// Spaces and special characters become hyphens, consecutive hyphens collapse to one.
|
||||
// Preserves: letters, digits, hyphens, plus signs (+), and dots (.)
|
||||
func sanitizeWikiTitle(title string) string {
|
||||
title = strings.TrimSpace(title)
|
||||
title = strings.ReplaceAll(title, " ", "-")
|
||||
title = nonSlugRe.ReplaceAllString(title, "-")
|
||||
title = nonAlphanumRe.ReplaceAllString(title, "-")
|
||||
title = multiHyphenRe.ReplaceAllString(title, "-")
|
||||
title = strings.NewReplacer("-+-", "-", "+-", "-", "-+", "-").Replace(title) // clean stray plus signs
|
||||
title = strings.Trim(title, "-+.")
|
||||
title = strings.Trim(title, "-")
|
||||
return title
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user