mirror of
https://github.com/go-gitea/gitea
synced 2024-11-14 01:35:54 +01:00
Backport #26286 by @wxiaoguang 1. Allow leading and trailing spaces by user input, these spaces have already been trimmed at backend 2. Allow using dots in the topic Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
a57568bad7
commit
fcd055c34a
@ -22,7 +22,7 @@ func init() {
|
|||||||
db.RegisterModel(new(RepoTopic))
|
db.RegisterModel(new(RepoTopic))
|
||||||
}
|
}
|
||||||
|
|
||||||
var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
|
var topicPattern = regexp.MustCompile(`^[a-z0-9][-.a-z0-9]*$`)
|
||||||
|
|
||||||
// Topic represents a topic of repositories
|
// Topic represents a topic of repositories
|
||||||
type Topic struct {
|
type Topic struct {
|
||||||
|
@ -69,6 +69,7 @@ func TestAddTopic(t *testing.T) {
|
|||||||
func TestTopicValidator(t *testing.T) {
|
func TestTopicValidator(t *testing.T) {
|
||||||
assert.True(t, repo_model.ValidateTopic("12345"))
|
assert.True(t, repo_model.ValidateTopic("12345"))
|
||||||
assert.True(t, repo_model.ValidateTopic("2-test"))
|
assert.True(t, repo_model.ValidateTopic("2-test"))
|
||||||
|
assert.True(t, repo_model.ValidateTopic("foo.bar"))
|
||||||
assert.True(t, repo_model.ValidateTopic("test-3"))
|
assert.True(t, repo_model.ValidateTopic("test-3"))
|
||||||
assert.True(t, repo_model.ValidateTopic("first"))
|
assert.True(t, repo_model.ValidateTopic("first"))
|
||||||
assert.True(t, repo_model.ValidateTopic("second-test-topic"))
|
assert.True(t, repo_model.ValidateTopic("second-test-topic"))
|
||||||
@ -77,4 +78,5 @@ func TestTopicValidator(t *testing.T) {
|
|||||||
assert.False(t, repo_model.ValidateTopic("$fourth-test,topic"))
|
assert.False(t, repo_model.ValidateTopic("$fourth-test,topic"))
|
||||||
assert.False(t, repo_model.ValidateTopic("-fifth-test-topic"))
|
assert.False(t, repo_model.ValidateTopic("-fifth-test-topic"))
|
||||||
assert.False(t, repo_model.ValidateTopic("sixth-go-project-topic-with-excess-length"))
|
assert.False(t, repo_model.ValidateTopic("sixth-go-project-topic-with-excess-length"))
|
||||||
|
assert.False(t, repo_model.ValidateTopic(".foo"))
|
||||||
}
|
}
|
||||||
|
@ -2484,7 +2484,7 @@ tag.create_success = Tag "%s" has been created.
|
|||||||
topic.manage_topics = Manage Topics
|
topic.manage_topics = Manage Topics
|
||||||
topic.done = Done
|
topic.done = Done
|
||||||
topic.count_prompt = You cannot select more than 25 topics
|
topic.count_prompt = You cannot select more than 25 topics
|
||||||
topic.format_prompt = Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
topic.format_prompt = Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
|
||||||
|
|
||||||
find_file.go_to_file = Go to file
|
find_file.go_to_file = Go to file
|
||||||
find_file.no_matching = No matching file found
|
find_file.no_matching = No matching file found
|
||||||
|
@ -166,7 +166,7 @@ export function initRepoTopicBar() {
|
|||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
type: 'validateTopic',
|
type: 'validateTopic',
|
||||||
value: /^[a-z0-9][a-z0-9-]{0,35}$/,
|
value: /^\s*[a-z0-9][-.a-z0-9]{0,35}\s*$/,
|
||||||
prompt: topicPrompts.formatPrompt
|
prompt: topicPrompts.formatPrompt
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user