Skip to content

Commit 6a35cc4

Browse files
committed
compose [nfc]: Simplify inlineLink by dropping null destination
Now that the caller is passing a string instead of a Uri object, the caller that wants an empty string here can just pass an empty string.
1 parent 2e06a67 commit 6a35cc4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/model/compose.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ String wildcardMention(WildcardMentionOption wildcardOption, {
188188
/// result may be surprising.
189189
///
190190
/// The part between "(" and ")" is just a "link destination" (no "link title").
191-
/// That destination is the string [destination], if provided.
191+
/// That destination is the string [destination].
192192
/// If [destination] has parentheses in it, the result may be surprising.
193193
// TODO: Try harder to guarantee output that creates an inline link,
194194
// and in particular, the intended one. We could help with this by escaping
@@ -199,8 +199,8 @@ String wildcardMention(WildcardMentionOption wildcardOption, {
199199
// > Backtick code spans, autolinks, and raw HTML tags bind more tightly
200200
// > than the brackets in link text. Thus, for example, [foo`]` could not be
201201
// > a link text, since the second ] is part of a code span.
202-
String inlineLink(String visibleText, String? destination) {
203-
return '[$visibleText](${destination ?? ''})';
202+
String inlineLink(String visibleText, String destination) {
203+
return '[$visibleText]($destination)';
204204
}
205205

206206
/// What we show while fetching the target message's raw Markdown.

lib/widgets/compose_box.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class ComposeContentController extends ComposeController<ContentValidationError>
350350
final tag = _nextUploadTag;
351351
_nextUploadTag += 1;
352352
final linkText = zulipLocalizations.composeBoxUploadingFilename(filename);
353-
final placeholder = inlineLink(linkText, null);
353+
final placeholder = inlineLink(linkText, '');
354354
_uploads[tag] = (filename: filename, placeholder: placeholder);
355355
notifyListeners(); // _uploads change could affect validationErrors
356356
value = value.replaced(insertionIndex(), '$placeholder\n\n');

test/model/compose_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ hello
320320

321321
test('inlineLink', () {
322322
check(inlineLink('CZO', 'https://chat.zulip.org/')).equals('[CZO](https://chat.zulip.org/)');
323-
check(inlineLink('Uploading file.txt…', null)).equals('[Uploading file.txt…]()');
323+
check(inlineLink('Uploading file.txt…', '')).equals('[Uploading file.txt…]()');
324324
check(inlineLink('IMG_2488.png', '/user_uploads/2/a3/ucEMyjxk90mcNF0y9rmW5XKO/IMG_2488.png'))
325325
.equals('[IMG_2488.png](/user_uploads/2/a3/ucEMyjxk90mcNF0y9rmW5XKO/IMG_2488.png)');
326326
});

0 commit comments

Comments
 (0)