mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-30 06:03:45 +01:00
Merge branch 'master' into dev
This commit is contained in:
commit
1d2970c3c5
@ -53,7 +53,7 @@ func ParseRepository(repository string) (project, rest string) {
|
||||
rest = repository
|
||||
return
|
||||
}
|
||||
index := strings.LastIndex(repository, "/")
|
||||
index := strings.Index(repository, "/")
|
||||
project = repository[0:index]
|
||||
rest = repository[index+1:]
|
||||
return
|
||||
|
@ -65,10 +65,10 @@ func TestParseRepository(t *testing.T) {
|
||||
|
||||
repository = "library/test/ubuntu"
|
||||
project, rest = ParseRepository(repository)
|
||||
if project != "library/test" {
|
||||
if project != "library" {
|
||||
t.Errorf("unexpected project: %s != %s", project, "library/test")
|
||||
}
|
||||
if rest != "ubuntu" {
|
||||
if rest != "test/ubuntu" {
|
||||
t.Errorf("unexpected rest: %s != %s", rest, "ubuntu")
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ func TriggerReplication(policyID int64, repository string,
|
||||
func GetPoliciesByRepository(repository string) ([]*models.RepPolicy, error) {
|
||||
repository = strings.TrimSpace(repository)
|
||||
repository = strings.TrimRight(repository, "/")
|
||||
projectName := repository[:strings.LastIndex(repository, "/")]
|
||||
projectName, _ := utils.ParseRepository(repository)
|
||||
|
||||
project, err := dao.GetProjectByName(projectName)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user