Skip to content

Commit 6973de9

Browse files
committed
Merge branch 'custom-list-crashes-when-naming-a-list-with-the-name-of-an-ios-599'
2 parents 8f8bd1d + c3d575e commit 6973de9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ios/MullvadSettings/CustomListRepository.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ public struct CustomListRepository: CustomListRepositoryProtocol {
3939
public func save(list: CustomList) throws {
4040
var lists = fetchAll()
4141

42-
if let index = lists.firstIndex(where: { $0.id == list.id }) {
42+
if let listWithSameName = lists.first(where: { $0.name.caseInsensitiveCompare(list.name) == .orderedSame }),
43+
listWithSameName.id != list.id {
44+
throw CustomRelayListError.duplicateName
45+
} else if let index = lists.firstIndex(where: { $0.id == list.id }) {
4346
lists[index] = list
4447
try write(lists)
45-
} else if lists.contains(where: { $0.name == list.name }) {
46-
throw CustomRelayListError.duplicateName
4748
} else {
4849
lists.append(list)
4950
try write(lists)

0 commit comments

Comments
 (0)