summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-04-15 11:30:34 +0200
committerBug Magnet <marco.nikic@mullvad.net>2024-04-15 11:30:34 +0200
commit6973de9c7f484e1d6f1013d1febfc0e94ed9d137 (patch)
tree2bf50aed27e60e84e376d2b94ea3a1a95d465532
parent8f8bd1d1cbeb3fefa466bdaca5c03e6fe4087833 (diff)
parentc3d575e11f42e13553a34c13da6c9e1f6c24289f (diff)
downloadmullvadvpn-6973de9c7f484e1d6f1013d1febfc0e94ed9d137.tar.xz
mullvadvpn-6973de9c7f484e1d6f1013d1febfc0e94ed9d137.zip
Merge branch 'custom-list-crashes-when-naming-a-list-with-the-name-of-an-ios-599'
-rw-r--r--ios/MullvadSettings/CustomListRepository.swift7
1 files changed, 4 insertions, 3 deletions
diff --git a/ios/MullvadSettings/CustomListRepository.swift b/ios/MullvadSettings/CustomListRepository.swift
index 4466b2f9aa..c6709782e2 100644
--- a/ios/MullvadSettings/CustomListRepository.swift
+++ b/ios/MullvadSettings/CustomListRepository.swift
@@ -39,11 +39,12 @@ public struct CustomListRepository: CustomListRepositoryProtocol {
public func save(list: CustomList) throws {
var lists = fetchAll()
- if let index = lists.firstIndex(where: { $0.id == list.id }) {
+ if let listWithSameName = lists.first(where: { $0.name.caseInsensitiveCompare(list.name) == .orderedSame }),
+ listWithSameName.id != list.id {
+ throw CustomRelayListError.duplicateName
+ } else if let index = lists.firstIndex(where: { $0.id == list.id }) {
lists[index] = list
try write(lists)
- } else if lists.contains(where: { $0.name == list.name }) {
- throw CustomRelayListError.duplicateName
} else {
lists.append(list)
try write(lists)