mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 20:09:23 +00:00
Merge pull request #395 from cypherstack/fix/epic-address
Strip "mailto:" prefix and "/" suffix from pasted EPIC addresses
This commit is contained in:
commit
8941b70a22
2 changed files with 25 additions and 10 deletions
|
@ -591,7 +591,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
_address = _address!.substring(0, _address!.indexOf("\n"));
|
_address = _address!.substring(0, _address!.indexOf("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToController.text = httpXOREpicBox(_address!);
|
sendToController.text = formatAddress(_address!);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -923,9 +923,8 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
if (coin ==
|
if (coin ==
|
||||||
Coin.epicCash) {
|
Coin.epicCash) {
|
||||||
// strip http:// and https:// if content contains @
|
// strip http:// and https:// if content contains @
|
||||||
content =
|
content = formatAddress(
|
||||||
httpXOREpicBox(
|
content);
|
||||||
content);
|
|
||||||
}
|
}
|
||||||
sendToController.text =
|
sendToController.text =
|
||||||
content;
|
content;
|
||||||
|
@ -1778,13 +1777,21 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip http:// and https:// if epicAddress contains @
|
String formatAddress(String epicAddress) {
|
||||||
String httpXOREpicBox(String epicAddress) {
|
// strip http:// or https:// prefixes if the address contains an @ symbol (and is thus an epicbox address)
|
||||||
if ((epicAddress.startsWith("http://") ||
|
if ((epicAddress.startsWith("http://") ||
|
||||||
epicAddress.startsWith("https://")) &&
|
epicAddress.startsWith("https://")) &&
|
||||||
epicAddress.contains("@")) {
|
epicAddress.contains("@")) {
|
||||||
epicAddress = epicAddress.replaceAll("http://", "");
|
epicAddress = epicAddress.replaceAll("http://", "");
|
||||||
epicAddress = epicAddress.replaceAll("https://", "");
|
epicAddress = epicAddress.replaceAll("https://", "");
|
||||||
}
|
}
|
||||||
|
// strip mailto: prefix
|
||||||
|
if (epicAddress.startsWith("mailto:")) {
|
||||||
|
epicAddress = epicAddress.replaceAll("mailto:", "");
|
||||||
|
}
|
||||||
|
// strip / suffix if the address contains an @ symbol (and is thus an epicbox address)
|
||||||
|
if (epicAddress.endsWith("/") && epicAddress.contains("@")) {
|
||||||
|
epicAddress = epicAddress.substring(0, epicAddress.length - 1);
|
||||||
|
}
|
||||||
return epicAddress;
|
return epicAddress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,7 +580,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
|
|
||||||
if (coin == Coin.epicCash) {
|
if (coin == Coin.epicCash) {
|
||||||
// strip http:// and https:// if content contains @
|
// strip http:// and https:// if content contains @
|
||||||
content = httpXOREpicBox(content);
|
content = formatAddress(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToController.text = content;
|
sendToController.text = content;
|
||||||
|
@ -758,7 +758,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
_address = _address!.substring(0, _address!.indexOf("\n"));
|
_address = _address!.substring(0, _address!.indexOf("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToController.text = httpXOREpicBox(_address!);
|
sendToController.text = formatAddress(_address!);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1345,13 +1345,21 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip http:// and https:// if epicAddress contains @
|
String formatAddress(String epicAddress) {
|
||||||
String httpXOREpicBox(String epicAddress) {
|
// strip http:// or https:// prefixes if the address contains an @ symbol (and is thus an epicbox address)
|
||||||
if ((epicAddress.startsWith("http://") ||
|
if ((epicAddress.startsWith("http://") ||
|
||||||
epicAddress.startsWith("https://")) &&
|
epicAddress.startsWith("https://")) &&
|
||||||
epicAddress.contains("@")) {
|
epicAddress.contains("@")) {
|
||||||
epicAddress = epicAddress.replaceAll("http://", "");
|
epicAddress = epicAddress.replaceAll("http://", "");
|
||||||
epicAddress = epicAddress.replaceAll("https://", "");
|
epicAddress = epicAddress.replaceAll("https://", "");
|
||||||
}
|
}
|
||||||
|
// strip mailto: prefix
|
||||||
|
if (epicAddress.startsWith("mailto:")) {
|
||||||
|
epicAddress = epicAddress.replaceAll("mailto:", "");
|
||||||
|
}
|
||||||
|
// strip / suffix if the address contains an @ symbol (and is thus an epicbox address)
|
||||||
|
if (epicAddress.endsWith("/") && epicAddress.contains("@")) {
|
||||||
|
epicAddress = epicAddress.substring(0, epicAddress.length - 1);
|
||||||
|
}
|
||||||
return epicAddress;
|
return epicAddress;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue