Skip to content

Return guesses as Float for empty password#119

Merged
orien merged 1 commit into
masterfrom
fix-empty-password-guesses-type
May 28, 2026
Merged

Return guesses as Float for empty password#119
orien merged 1 commit into
masterfrom
fix-empty-password-guesses-type

Conversation

@orien

@orien orien commented May 28, 2026

Copy link
Copy Markdown
Member

Context

Zxcvbn.test('') returns guesses: 1 (Integer). All other passwords go through the DP scoring path and return guesses as Float. The JS library also returns 1 for empty password, so the value is correct — only the Ruby type is inconsistent.

Changes

Change the empty-password short-circuit in Scorer#most_guessable_match_sequence from 1 to 1.0.

Consequences

guesses is now consistently Float across all inputs.

Non-empty passwords return Float through the DP scoring path. Empty
password short-circuits with an Integer 1, producing a type inconsistency.
@orien orien merged commit 9b939fe into master May 28, 2026
10 checks passed
@orien orien deleted the fix-empty-password-guesses-type branch May 28, 2026 02:24
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