Skip to content

fix(username): drop a leading @ in the validator - #742

Merged
bmc08gt merged 1 commit into
mainfrom
fix/username-leading-at
Sep 9, 2026
Merged

bmc08gt merged 1 commit into
mainfrom
fix/username-leading-at

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Pasting @taylor into either username field failed: the claim screen raised Invalid Characters and the lookup screen raised Username Not Found. UsernameValidator only trimmed whitespace and lowercased, so the @ reached Username.init? and failed the ^[a-z0-9_]{2,15}$ charset.

normalized now also drops one leading @. That is the validator's existing job as the one place a typed handle is rewritten before the model, and both validate and failure(for:) share it, so both screens are covered without touching either. The claim screen's canSubmit already compares through the validator, so @taylor against a current taylor correctly reads as no edit.

Edges, pinned by new tests in UsernameValidatorTests:

  • @taylor and @Taylor accept as taylor
  • @@taylor and tay@lor report invalid characters
  • a lone @ reports too short

The fields still accept the keystroke and show what was typed. Filtering @ at the field would be the only character-level filter on iOS, and the entry screen's comment explains why it filters nothing beyond case. Android strips the @ in its field's input transformation instead, so both platforms submit the same value.

Ran ./Scripts/test.sh FlipcashCoreTests/UsernameValidatorTests: 19 tests pass.

A handle pasted from a profile arrives as `@taylor`, and the validator
passed it through to `Username.init?`, which rejects the `@` against
the server's `^[a-z0-9_]{2,15}$` charset. The claim screen answered with
the Invalid Characters dialog and the lookup screen with Username Not
Found, for a handle the user could see was right.

`normalized` now strips one leading `@` after trimming and lowercasing.
Both `validate` and `failure(for:)` run through it, so both screens pick
the change up, and `canSubmit` on the claim screen already compares
through the validator, so `@taylor` against a current `taylor` reads as
no edit. Only one `@` goes: `@@taylor` still reports invalid characters,
and a lone `@` reports too short.

Android already lands on the same submitted value, by dropping the `@`
in the field's input transformation. iOS keeps the raw input on screen
on purpose, so the rejection dialogs stay reachable.
@bmc08gt bmc08gt self-assigned this Sep 9, 2026
@bmc08gt
bmc08gt merged commit c753f90 into main Sep 9, 2026
1 check passed
bmc08gt added a commit that referenced this pull request Sep 11, 2026
…discrete-curve

* origin/main: (27 commits)
  fix(database): share one SQLite writer per owner and take write locks up front (#759)
  feat(chat): declare the payment action on tip DM payments (#752)
  refactor(chat): drop the deprecated new_messages overlay (#757)
  feat(notifications): write prefetched messages into the shared store (#756)
  refactor(store): move the persistence layer into a shared FlipcashStore package (#755)
  feat(database): move the SQLite store into the App Group container (#754)
  feat(database): open the store on demand, close it on background (#753)
  feat(nse): extension crash reporting, a WAL checkpoint, and on-device push hooks (#751)
  feat(home): long-press the You tab to open the account switcher (#749)
  fix(tests): reset Photos access before the previous app instance lingers (#746)
  chore: bump version to 2026.9.2 (#745)
  revert: back out the Coinbase Stable Swapper authority migration (#747) (#750)
  fix(swap): follow the Coinbase Stable Swapper authority migration (#747)
  fix(tests): cancel a cash link through the details screen (#744)
  fix(chat): make the whole Send Cash pill tappable while it stands alone (#743)
  fix(username): drop a leading @ in the validator (#742)
  fix(chat): scope the send-button spring to the button (#741)
  fix(transactions): tighten the details card stack and drop the header badge (#740)
  fix(transactions): draw View in Chat as a card, not the primary action (#739)
  feat(chat): flash the message a reply-quote jump lands on (#738)
  ...

# Conflicts:
#	Code.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	FlipcashCore/Package.swift
@bmc08gt
bmc08gt deleted the fix/username-leading-at branch September 15, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant