Skip to content

Commit 535df3d

Browse files
committed
Remove MultipleResultsException
As this can never happen without checking for separators.
1 parent 99a41e4 commit 535df3d

3 files changed

Lines changed: 2 additions & 20 deletions

File tree

src/Hashids.net/Hashids.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ public long DecodeSingleLong(string hash)
178178
return number switch
179179
{
180180
-1 => throw new NoResultException("The hash provided yielded no result."),
181-
-2 => throw new MultipleResultsException("The hash provided yielded more than one result."),
182181
_ => number,
183182
};
184183
}
@@ -206,7 +205,6 @@ public virtual int DecodeSingle(string hash)
206205
return number switch
207206
{
208207
-1 => throw new NoResultException("The hash provided yielded no result."),
209-
-2 => throw new MultipleResultsException("The hash provided yielded more than one result."),
210208
_ => (int)number,
211209
};
212210
}
@@ -418,11 +416,6 @@ private long GetNumberFrom(string hash)
418416

419417
var hashBuffer = hashBreakdown.Slice(1);
420418

421-
var indexOfSep = hashBuffer.IndexOfAny(_seps);
422-
423-
if (indexOfSep != -1)
424-
return -2;
425-
426419
Span<char> alphabet = _alphabet.Length < 512 ? stackalloc char[_alphabet.Length] : new char[_alphabet.Length];
427420
_alphabet.CopyTo(alphabet);
428421

src/Hashids.net/MultipleResultsException.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/Hashids.net.test/GeneralTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void SingleInt_DecodesSingleNumber()
5858
_hashids.DecodeSingle("yj8").Should().Be(303);
5959

6060
Assert.Throws<NoResultException>(() => _hashids.DecodeSingle(string.Empty));
61-
Assert.Throws<MultipleResultsException>(() => _hashids.DecodeSingle("aBMswoO2UB3Sj"));
61+
Assert.Throws<NoResultException>(() => _hashids.DecodeSingle("aBMswoO2UB3Sj"));
6262
}
6363

6464
[Fact]
@@ -120,7 +120,7 @@ public void SingleLong_DecodesSingleNumber()
120120
_hashids.DecodeSingleLong("jvNx4BjM5KYjv").Should().Be(long.MaxValue);
121121

122122
Assert.Throws<NoResultException>(() => _hashids.DecodeSingleLong(string.Empty));
123-
Assert.Throws<MultipleResultsException>(() => _hashids.DecodeSingleLong("6gH3kPY7MJ9zjM3"));
123+
Assert.Throws<NoResultException>(() => _hashids.DecodeSingleLong("6gH3kPY7MJ9zjM3"));
124124
}
125125

126126
[Fact]

0 commit comments

Comments
 (0)