Skip to content

Commit 81656f4

Browse files
committed
emoji: Parse URLs the same way for validation as for use
I think this change might be NFC, but I'm not sure. The situation where it could change the behavior is if there's some URL string that would be accepted by `Uri.parse`, but rejected by `Uri.resolve` with the realm URL as base URL, or vice versa. If there is any such situation, then this behavior is more accurate. If there isn't, then this is just a small simplification. Noticed this because it's one of the handful of references to the store's realmUrl, and another one is a call to tryResolveUrl.
1 parent 6706ce9 commit 81656f4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/model/emoji.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,19 @@ class EmojiStoreImpl extends PerAccountStoreBase with EmojiStore {
192192
required String? stillUrl,
193193
required String emojiName,
194194
}) {
195-
final source = Uri.tryParse(sourceUrl);
196-
if (source == null) return TextEmojiDisplay(emojiName: emojiName);
195+
final resolvedUrl = tryResolveUrl(realmUrl, sourceUrl);
196+
if (resolvedUrl == null) return TextEmojiDisplay(emojiName: emojiName);
197197

198-
Uri? still;
198+
Uri? resolvedStillUrl;
199199
if (stillUrl != null) {
200-
still = Uri.tryParse(stillUrl);
201-
if (still == null) return TextEmojiDisplay(emojiName: emojiName);
200+
resolvedStillUrl = tryResolveUrl(realmUrl, stillUrl);
201+
if (resolvedStillUrl == null) return TextEmojiDisplay(emojiName: emojiName);
202202
}
203203

204204
return ImageEmojiDisplay(
205205
emojiName: emojiName,
206-
resolvedUrl: realmUrl.resolveUri(source),
207-
resolvedStillUrl: still == null ? null : realmUrl.resolveUri(still),
206+
resolvedUrl: resolvedUrl,
207+
resolvedStillUrl: resolvedStillUrl,
208208
);
209209
}
210210

0 commit comments

Comments
 (0)