Browse Source

Using strings.HasPrefix(...) will misjudgement

`strings.HasPrefix(access.RepoName, uname)` can't handle the situation which like following in access table.

	user_name | repo_name
	----------+-------------
	toby      | toby/blog
	toby      | toby/test
	toby      | tobyzxj/blog
	toby      | tobyzxj/test
toby.zxj 10 years ago
parent
commit
a13a6b14ec
1 changed files with 3 additions and 3 deletions
  1. 3 3
      models/repo.go

+ 3 - 3
models/repo.go

@@ -831,11 +831,11 @@ func GetCollaborativeRepos(uname string) ([]*Repository, error) {
 
 	repos := make([]*Repository, 0, 10)
 	for _, access := range accesses {
-		if strings.HasPrefix(access.RepoName, uname) {
+		infos := strings.Split(access.RepoName, "/")
+		if infos[0] == uname {
 			continue
 		}
-
-		infos := strings.Split(access.RepoName, "/")
+		
 		u, err := GetUserByName(infos[0])
 		if err != nil {
 			return nil, err