fix for Mastadon lookup (#3272)
Serhii committed
Jun 1, 2026 at 20:13 UTC
cfe332a8783319eda553eca2a485df01e6013faa
1 file changed
+11
-2
lib/entities/parse_address_from_domain.dart
+11
-2
@@ -216,6 +216,14 @@ class AddressResolver {
216
return emailRegex.hasMatch(address);
217
}
218
219
+ String _stripHtmlTags(String value) {
220
+ return value
221
+ .replaceAll(RegExp(r'<br\s*/?>', caseSensitive: false), '\n')
222
+ .replaceAll(RegExp(r'</p\s*>', caseSensitive: false), '\n')
223
+ .replaceAll(RegExp(r'<[^>]*>'), '')
224
+ .trim();
225
+ }
226
+
227
Future<ParsedAddress> resolve(BuildContext context, String text, CryptoCurrency currency) async {
228
final ticker = currency.title;
229
try {
@@ -348,7 +356,8 @@ class AddressResolver {
356
await MastodonAPI.lookupUserByUserName(userName: userName, apiHost: hostName);
357
358
if (mastodonUser != null) {
351
- String? addressFromBio = extractAddressByType(raw: mastodonUser.note, type: currency, requireSurroundingWhitespaces: true);
359
+ final mastodonNote = _stripHtmlTags(mastodonUser.note);
360
+ String? addressFromBio = extractAddressByType(raw: mastodonNote, type: currency, requireSurroundingWhitespaces: true);
361
362
if (addressFromBio != null && addressFromBio.isNotEmpty) {
363
return ParsedAddress.fetchMastodonAddress(
@@ -361,7 +370,7 @@ class AddressResolver {
370
await MastodonAPI.getPinnedPosts(userId: mastodonUser.id, apiHost: hostName);
371
372
if (pinnedPosts.isNotEmpty) {
364
- final userPinnedPostsText = pinnedPosts.map((item) => item.content).join('\n');
373
+ final userPinnedPostsText = pinnedPosts.map((item) => _stripHtmlTags(item.content)).join('\n');
374
String? addressFromPinnedPost =
375
extractAddressByType(raw: userPinnedPostsText, type: currency,
376
requireSurroundingWhitespaces: true);