diff options
author | toby.zxj <toby.zxj@gmail.com> | 2014-06-11 16:54:25 +0800 |
---|---|---|
committer | toby.zxj <toby.zxj@gmail.com> | 2014-06-11 16:54:25 +0800 |
commit | a13a6b14ec4ab8e9660fd59d7abe00e3d3666f9f (patch) | |
tree | 31ca00259ab5cd69ff4affcb51f632ab1fedb440 | |
parent | a3e1383cac3dfa2a71b04b47a295e9836fcb0d50 (diff) | |
download | gitea-a13a6b14ec4ab8e9660fd59d7abe00e3d3666f9f.tar.gz gitea-a13a6b14ec4ab8e9660fd59d7abe00e3d3666f9f.zip |
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
-rw-r--r-- | models/repo.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go index 3eca78c4b9..7eab83c217 100644 --- a/models/repo.go +++ b/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 |