diff options
| author | Christian Cleberg <[email protected]> | 2026-07-25 16:47:21 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-07-25 16:47:21 -0500 |
| commit | 522d04a8233f66b81abcae4dd04df02d342f35be (patch) | |
| tree | 642109f69fd87def280b94b126d2f8c5227edf19 /octosentry/SecurityEventStore.swift | |
| parent | 0b5cc04f3ce71875a930c9a7c4b6cb82350718d9 (diff) | |
| download | octosentry-1.0.1.tar.gz octosentry-1.0.1.tar.bz2 octosentry-1.0.1.zip | |
Normalize repo watch-list entries in addRepo1.0.1
Store the canonical "owner/repo" reconstructed from the parsed parts
instead of the raw input, so stray slashes (e.g. "owner/repo/") can't
create an entry that silently 404s on refresh. Also compare
case-insensitively for duplicates, since GitHub owner/repo names are
case-insensitive.
Bumps marketing version to 1.0.1.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Diffstat (limited to 'octosentry/SecurityEventStore.swift')
| -rw-r--r-- | octosentry/SecurityEventStore.swift | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/octosentry/SecurityEventStore.swift b/octosentry/SecurityEventStore.swift index 8f3d0f5..bb92af9 100644 --- a/octosentry/SecurityEventStore.swift +++ b/octosentry/SecurityEventStore.swift @@ -121,13 +121,21 @@ final class SecurityEventStore { watchListErrorMessage = "Enter a repo as \"owner/repo\"." return } + // Store the canonical "owner/repo" rather than the raw input, so + // stray slashes (e.g. "owner/repo/") can't produce a malformed + // entry that silently 404s on refresh. + let repoFullName = "\(parts[0])/\(parts[1])" var state = await persistenceStore.load() - guard !state.watchedRepos.contains(trimmed) else { - watchListErrorMessage = "\(trimmed) is already watched." + // GitHub owner/repo names are case-insensitive, so treat entries + // that differ only in case as the same watched repo. + guard !state.watchedRepos.contains(where: { + $0.caseInsensitiveCompare(repoFullName) == .orderedSame + }) else { + watchListErrorMessage = "\(repoFullName) is already watched." return } - state.watchedRepos.append(trimmed) + state.watchedRepos.append(repoFullName) await persistenceStore.save(state) watchedRepos = state.watchedRepos |
