From 8236125274039eceed49fb3c00a8d2b6703baa8a Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Wed, 21 Feb 2024 18:48:11 +0400 Subject: [PATCH] fix: Uri truncated with http and https --- .../mirai_web3/lib/services/web_modal_service.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/mirai_web3/lib/services/web_modal_service.dart b/packages/mirai_web3/lib/services/web_modal_service.dart index 234acfc3..1ca8015d 100644 --- a/packages/mirai_web3/lib/services/web_modal_service.dart +++ b/packages/mirai_web3/lib/services/web_modal_service.dart @@ -328,7 +328,8 @@ class Web3ModalService { tokenName: contractToken.name, timestamp: "", explorer: Uri.https( - "${_service.selectedChain?.blockExplorer?.url.truncatedSlash}/tx/${l.blockHash}"), + "${_service.selectedChain?.blockExplorer?.url.truncated}", + "/tx/${l.blockHash}"), ), ); } @@ -366,11 +367,14 @@ class Web3ModalService { } extension StringExt on String? { - String get truncatedSlash { + String get truncated { if (this == null || this!.isEmpty) { return W3MChainPresets.chains['1']?.blockExplorer?.url ?? ''; - } else if (this!.endsWith('/')) { - return this!.substring(0, (this!.length) - 1); + } else if (this!.contains('http') || this!.endsWith('/')) { + String truncated = this!.replaceAll('https://', ''); + truncated = truncated.replaceAll('http://', ''); + truncated = truncated.replaceAll('/', ''); + return truncated; } else { return this!; }