Skip to content

Commit 7b4a5df

Browse files
committed
internal_link: Reject unknown is operand.
Previously, `is` elements with operands other than `mentioned` are ignored when parsing internal links. When the remaining elements combined are recognized, some non-null narrows can be returned. Now `is` elements are never ignored, to avoid such false positives. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 0a9cf7f commit 7b4a5df

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/model/internal_link.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ Narrow? _interpretNarrowSegments(List<String> segments, PerAccountStore store) {
184184

185185
case _NarrowOperator.is_:
186186
if (isMentionedElement != null) return null;
187-
if (operand == 'mentioned') isMentionedElement = ApiNarrowIsMentioned();
187+
if (operand == 'mentioned') {
188+
isMentionedElement = ApiNarrowIsMentioned();
189+
} else {
190+
return null;
191+
}
188192

189193
case _NarrowOperator.near: // TODO(#82): support for near
190194
case _NarrowOperator.with_: // TODO(#683): support for with

test/model/internal_link_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ void main() {
239239
final testCases = [
240240
('/#narrow/stream/name/topic/', null), // missing operand
241241
('/#narrow/stream/name/unknown/operand/', null), // unknown operator
242+
('/#narrow/is/starred', null), // unknown `is` operand
242243
];
243244
testExpectedNarrows(testCases, streams: streams);
244245
});

0 commit comments

Comments
 (0)