mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-30 03:21:23 +00:00
BitcoinURI: Allow uppercase schema.
This commit is contained in:
@@ -146,9 +146,10 @@ public class BitcoinURI {
|
||||
String blockchainInfoScheme = scheme + "://";
|
||||
String correctScheme = scheme + ":";
|
||||
String schemeSpecificPart;
|
||||
if (input.startsWith(blockchainInfoScheme)) {
|
||||
final String inputLc = input.toLowerCase(Locale.US);
|
||||
if (inputLc.startsWith(blockchainInfoScheme)) {
|
||||
schemeSpecificPart = input.substring(blockchainInfoScheme.length());
|
||||
} else if (input.startsWith(correctScheme)) {
|
||||
} else if (inputLc.startsWith(correctScheme)) {
|
||||
schemeSpecificPart = input.substring(correctScheme.length());
|
||||
} else {
|
||||
throw new BitcoinURIParseException("Unsupported URI scheme: " + uri.getScheme());
|
||||
|
@@ -29,6 +29,8 @@ import org.bitcoinj.core.SegwitAddress;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class BitcoinURITest {
|
||||
private BitcoinURI testObject = null;
|
||||
|
||||
@@ -101,6 +103,15 @@ public class BitcoinURITest {
|
||||
assertEquals("Unexpected label", 20, testObject.getAddress().getHash().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGood_uppercaseScheme() throws BitcoinURIParseException {
|
||||
testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME.toUpperCase(Locale.US) + ":" + MAINNET_GOOD_ADDRESS);
|
||||
assertEquals(MAINNET_GOOD_ADDRESS, testObject.getAddress().toString());
|
||||
assertNull("Unexpected amount", testObject.getAmount());
|
||||
assertNull("Unexpected label", testObject.getLabel());
|
||||
assertEquals("Unexpected label", 20, testObject.getAddress().getHash().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGood_segwit() throws BitcoinURIParseException {
|
||||
testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_SEGWIT_ADDRESS);
|
||||
|
Reference in New Issue
Block a user