Skip to content

Commit d77baa8

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 1964388 commit d77baa8

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

lib/model/internal_link.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Narrow? _interpretNarrowSegments(List<String> segments, PerAccountStore store) {
185185
case _NarrowOperator.is_:
186186
if (isMentionedElement != null) return null;
187187
if (operand == 'mentioned') isMentionedElement = ApiNarrowIsMentioned();
188+
return null;
188189

189190
case _NarrowOperator.near: // TODO(#82): support for near
190191
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)