Skip to content

Commit

Permalink
feat: allow delta to be null in sequence matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
SPodjasek committed Sep 1, 2023
1 parent 6c82bda commit 157fed5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/dart_zxcvbn/lib/src/matcher/sequence.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class SequenceMatcher extends Matcher {
}
}

if (lastDelta == null) throw Exception('lastDelta is null');

update(
i: i,
j: passwordLength - 1,
Expand All @@ -84,12 +82,12 @@ class SequenceMatcher extends Matcher {
void update({
required int i,
required int j,
required int delta,
required int? delta,
required String password,
required List<SequenceMatch> result,
}) {
if (j - i > 1 || delta.abs() == 1) {
final int absoluteDelta = delta.abs();
if (j - i > 1 || delta?.abs() == 1) {
final int absoluteDelta = delta?.abs() ?? 0;
if (absoluteDelta > 0 && absoluteDelta <= maxDelta) {
final token = password.substring(i, j + 1);
final (sequenceName, sequenceSpace) = getSequence(token);
Expand All @@ -100,7 +98,7 @@ class SequenceMatcher extends Matcher {
token: token,
sequenceName: sequenceName,
sequenceSpace: sequenceSpace,
ascending: delta > 0,
ascending: delta != null ? delta > 0 : false,
));
}
}
Expand Down

0 comments on commit 157fed5

Please sign in to comment.