Skip to content

Commit 10a1c34

Browse files
committed
fix(swp): we store urllist as empty string, when we split on newline we will get a slice length of 1 when urllist is empty string
1 parent c450245 commit 10a1c34

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/service/core/storage/postgres/postgres_workstations.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,25 @@ func (s *workstationsStorage) GetLastWorkstationsOnpremAllowList(ctx context.Con
9898
func (s *workstationsStorage) GetLastWorkstationsURLList(ctx context.Context, navIdent string) (*service.WorkstationURLList, error) {
9999
const op errs.Op = "workstationsStorage.GetLastWorkstationsURLListChange"
100100

101+
urlAllowList := []string{}
101102
raw, err := s.db.Querier.GetLastWorkstationsURLListChange(ctx, navIdent)
102103
if err != nil {
103104
if errors.Is(err, sql.ErrNoRows) {
104105
return &service.WorkstationURLList{
105-
URLAllowList: []string{},
106+
URLAllowList: urlAllowList,
106107
DisableGlobalAllowList: false,
107108
}, nil
108109
}
109110

110111
return nil, errs.E(errs.Database, service.CodeDatabase, op, err)
111112
}
112113

114+
if raw.UrlList != "" {
115+
urlAllowList = strings.Split(raw.UrlList, "\n")
116+
}
117+
113118
return &service.WorkstationURLList{
114-
URLAllowList: strings.Split(raw.UrlList, "\n"),
119+
URLAllowList: urlAllowList,
115120
DisableGlobalAllowList: raw.DisableGlobalUrlList,
116121
}, nil
117122
}

0 commit comments

Comments
 (0)