Skip to content

Commit

Permalink
fix: Added extra slash truncation from the string uri of block expl…
Browse files Browse the repository at this point in the history
…orer
  • Loading branch information
i-asimkhan committed Feb 21, 2024
1 parent c178a59 commit 3268fed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/mirai_web3/lib/services/web_modal_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class Web3ModalService {
tokenName: contractToken.name,
timestamp: "",
explorer: Uri.https(
"${_service.selectedChain?.blockExplorer?.url}/tx/${l.blockHash}"),
"${_service.selectedChain?.blockExplorer?.url.truncatedSlash}/tx/${l.blockHash}"),
),
);
}
Expand Down Expand Up @@ -364,3 +364,15 @@ class Web3ModalService {
await _service.disconnect();
}
}

extension StringExt on String? {
String get truncatedSlash {
if (this == null || this!.isEmpty) {
return W3MChainPresets.chains['1']?.blockExplorer?.url ?? '';
} else if (this!.endsWith('/')) {
return this!.substring(0, (this!.length) - 1);
} else {
return this!;
}
}
}

0 comments on commit 3268fed

Please sign in to comment.