-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topics are (inconsistently) converted to lower-case #5222
Comments
It is intentionally converted to lowercase to not have problems later and also have compatibility with GitHub (it also lowercases topics) |
See here: #5171 (comment) and here: https://blog.gitea.io/2018/08/gitea-1.5.0-is-released/ I don't agree with "not have problems later", it is easy enough to do case-insensitive comparisons; and I don't mind being different from GitHub where it is possible to do it better than GitHub 😃 (better in this case: the user has the freedom to decide) |
@michael-brade but than there still be problem anyway as most probably someone will decide in your place. Let's say someone in other org/repo will add topic |
@lafriks oh! you're right, I didn't think about that... so then what about this: no conversion at all, and case-sensitive comparisons. Then everyone can do whatever they want, since (The other possibility would be to have topics local to each organization or user, but I don't think it would have any advantage over other solutions and might really lead to trouble 😄) |
I don't think that problem is currently present, in database all topics are currently already lowercase so it is only UI bug that needs to be fixed |
I think you misunderstood this one. With clutter I meant items you don't want to see in general, with typos of all sorts you can imagine. Adding uppercase letters doesn't make this kind of clutter worse. The only solution to this would be to limit suggestions to those of the current user/org, but I don't think this would be easy. BTW: is it possible to delete a topic from the database by removing the last usage of it? |
I don't think topics are deleted when not used any more currently. As for being case insensitive I'm against it as it will add clutter and will render them less useful. Especially taking into account if used in future in federation when we get to that. |
Maybe we should add a whitelist to convert |
IMHO that is not needed as that will still not cover all |
Ok, I changed it for my own server to case-sensitive. And I have to say, gitea is really good code! It is very easy to find my way around in it and to understand what's going on. Lovely. If anyone is interested, here is the patch that makes Topics case-sensitive: diff --git a/models/topic.go b/models/topic.go
index 678795a3d..69071a39b 100644
--- a/models/topic.go
+++ b/models/topic.go
@@ -21,7 +21,7 @@ func init() {
)
}
-var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
+var topicPattern = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9-]*$`)
// Topic represents a topic of repositories
type Topic struct {
@@ -127,7 +127,7 @@ func SaveTopics(repoID int64, topicNames ...string) error {
var found bool
for _, t := range topics {
- if strings.EqualFold(topicName, t.Name) {
+ if topicName == t.Name {
found = true
break
}
@@ -141,7 +141,7 @@ func SaveTopics(repoID int64, topicNames ...string) error {
for _, t := range topics {
var found bool
for _, topicName := range topicNames {
- if strings.EqualFold(topicName, t.Name) {
+ if topicName == t.Name {
found = true
break
}
diff --git a/public/js/index.js b/public/js/index.js
index 0bc28c4f9..5351d4040 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -2523,12 +2523,12 @@ function initTopicbar() {
},
},
onLabelCreate: function(value) {
- value = value.toLowerCase().trim();
+ value = value.trim();
this.attr("data-value", value).contents().first().replaceWith(value);
return $(this);
},
onAdd: function(addedValue, addedText, $addedChoice) {
- addedValue = addedValue.toLowerCase().trim();
+ addedValue = addedValue.trim();
$($addedChoice).attr('data-value', addedValue);
$($addedChoice).attr('data-text', addedValue);
}
@@ -2553,7 +2553,7 @@ function initTopicbar() {
rules: [
{
type: 'validateTopic',
- value: /^[a-z0-9][a-z0-9-]{1,35}$/,
+ value: /^[A-Za-z0-9][A-Za-z0-9-]{1,35}$/,
prompt: topicPrompts.formatPrompt
},
{
diff --git a/routers/repo/topic.go b/routers/repo/topic.go
index 63fcf793f..3fa1205e7 100644
--- a/routers/repo/topic.go
+++ b/routers/repo/topic.go
@@ -30,7 +30,7 @@ func TopicsPost(ctx *context.Context) {
invalidTopics := make([]string, 0)
i := 0
for _, topic := range topics {
- topic = strings.TrimSpace(strings.ToLower(topic))
+ topic = strings.TrimSpace(topic)
// ignore empty string
if len(topic) > 0 {
topics[i] = topic |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions. |
This issue has been automatically closed because of inactivity. You can re-open it if needed. |
[x]
):Description
A stream of inconsistencies regarding case-sensitivity of topics:
What I would expect: keep the topic as it is, don't lowercase or uppercase it.
The text was updated successfully, but these errors were encountered: