Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Base62 {

private static final BigInteger BASE = BigInteger.valueOf(62);
private static final String DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static final Pattern DIGITS_PATTERN = Pattern.compile("[" + DIGITS + "]*");

/**
* Encodes a number using Base62 encoding.
Expand Down Expand Up @@ -63,7 +64,7 @@ static BigInteger decode(final String string, int bitLimit) {
return throwIllegalArgumentException("String '%s' must not be empty", string);
}

if (!Pattern.matches("[" + DIGITS + "]*", string)) {
if (!DIGITS_PATTERN.matcher(string).matches()) {
throwIllegalArgumentException("String '%s' contains illegal characters, only '%s' are allowed", string, DIGITS);
}

Expand Down