Skip to content

Commit

Permalink
fix: Uri truncated with http and https
Browse files Browse the repository at this point in the history
  • Loading branch information
i-asimkhan committed Feb 21, 2024
1 parent 3268fed commit 8236125
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/mirai_web3/lib/services/web_modal_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
),
);
}
Expand Down Expand Up @@ -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!;
}
Expand Down

0 comments on commit 8236125

Please sign in to comment.