SafeNames does not abbreviate first names #35216
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FND-1146: Fix the name abbreviation logic on section login page.
There were some documented problems with name abbreviations when one first-name was a strict subset of another. For instance, for the set of names
Anna, Annabel, Annabelle, Brad, Bradford, Bradlee, Bradley, Branford, Maria, Mariamu
the login page would show the following:Notice that
Anna
andMaria
have been reduced to one character, andAnnabel
has oddly been truncated to five characters.The logic abbreviating names here is designed to find the smallest unique prefix that can be used to tell two students with the same name apart; for example, reducing
Tom Sawyer, Tom Smith
toTom Sa, Tom Sm
. However, we never want to abbreviate a first name, and if the first name is already unique, we should be able to use it without trying to compute a minimum prefix.We already had logic to that effect here:
But
trie.words
gets all the words that start with a particular string. If you put inJohn Smith
andJohnny Smith
then trie.words("John").count is 2 even though the first name is unique.I've added a different check for first-name-uniqueness to fix this behavior. Now the login page looks like this:
Testing story
I've extended the existing test with new assertions capturing known problem cases.
Reviewer Checklist: