mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 02:09:29 +01:00
BitcoinURI: strip some whitespace from end of lines
This commit is contained in:
parent
d5d7fb0bcc
commit
1a5af67b73
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012, 2014 the original author or authors.
|
* Copyright 2012, 2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -152,7 +152,7 @@ public class BitcoinURI {
|
|||||||
// URI is formed as bitcoin:<address>?<query parameters>
|
// URI is formed as bitcoin:<address>?<query parameters>
|
||||||
// blockchain.info generates URIs of non-BIP compliant form bitcoin://address?....
|
// blockchain.info generates URIs of non-BIP compliant form bitcoin://address?....
|
||||||
// We support both until Ben fixes his code.
|
// We support both until Ben fixes his code.
|
||||||
|
|
||||||
// Remove the bitcoin scheme.
|
// Remove the bitcoin scheme.
|
||||||
// (Note: getSchemeSpecificPart() is not used as it unescapes the label and parse then fails.
|
// (Note: getSchemeSpecificPart() is not used as it unescapes the label and parse then fails.
|
||||||
// For instance with : bitcoin:129mVqKUmJ9uwPxKJBnNdABbuaaNfho4Ha?amount=0.06&label=Tom%20%26%20Jerry
|
// For instance with : bitcoin:129mVqKUmJ9uwPxKJBnNdABbuaaNfho4Ha?amount=0.06&label=Tom%20%26%20Jerry
|
||||||
@ -403,29 +403,29 @@ public class BitcoinURI {
|
|||||||
if (amount != null && amount.signum() < 0) {
|
if (amount != null && amount.signum() < 0) {
|
||||||
throw new IllegalArgumentException("Coin must be positive");
|
throw new IllegalArgumentException("Coin must be positive");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
String scheme = network.uriScheme();
|
String scheme = network.uriScheme();
|
||||||
builder.append(scheme).append(":").append(address);
|
builder.append(scheme).append(":").append(address);
|
||||||
|
|
||||||
boolean questionMarkHasBeenOutput = false;
|
boolean questionMarkHasBeenOutput = false;
|
||||||
|
|
||||||
if (amount != null) {
|
if (amount != null) {
|
||||||
builder.append(QUESTION_MARK_SEPARATOR).append(FIELD_AMOUNT).append("=");
|
builder.append(QUESTION_MARK_SEPARATOR).append(FIELD_AMOUNT).append("=");
|
||||||
builder.append(amount.toPlainString());
|
builder.append(amount.toPlainString());
|
||||||
questionMarkHasBeenOutput = true;
|
questionMarkHasBeenOutput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label != null && !"".equals(label)) {
|
if (label != null && !"".equals(label)) {
|
||||||
if (questionMarkHasBeenOutput) {
|
if (questionMarkHasBeenOutput) {
|
||||||
builder.append(AMPERSAND_SEPARATOR);
|
builder.append(AMPERSAND_SEPARATOR);
|
||||||
} else {
|
} else {
|
||||||
builder.append(QUESTION_MARK_SEPARATOR);
|
builder.append(QUESTION_MARK_SEPARATOR);
|
||||||
questionMarkHasBeenOutput = true;
|
questionMarkHasBeenOutput = true;
|
||||||
}
|
}
|
||||||
builder.append(FIELD_LABEL).append("=").append(encodeURLString(label));
|
builder.append(FIELD_LABEL).append("=").append(encodeURLString(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message != null && !"".equals(message)) {
|
if (message != null && !"".equals(message)) {
|
||||||
if (questionMarkHasBeenOutput) {
|
if (questionMarkHasBeenOutput) {
|
||||||
builder.append(AMPERSAND_SEPARATOR);
|
builder.append(AMPERSAND_SEPARATOR);
|
||||||
@ -434,13 +434,13 @@ public class BitcoinURI {
|
|||||||
}
|
}
|
||||||
builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message));
|
builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode a string using URL encoding
|
* Encode a string using URL encoding
|
||||||
*
|
*
|
||||||
* @param stringToEncode The string to URL encode
|
* @param stringToEncode The string to URL encode
|
||||||
*/
|
*/
|
||||||
static String encodeURLString(String stringToEncode) {
|
static String encodeURLString(String stringToEncode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user