mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
hashchange: Handle trailing slashes in narrowing URLs.
Fixes #9305. Empty operators are not allowed while parsing narrowing URLs. `parse_narrow` stops parsing further if it encounters an empty string operator.
This commit is contained in:
committed by
Tim Abbott
parent
83ee8211a8
commit
f0d874d51f
@@ -81,6 +81,18 @@ run_test('operators_round_trip', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('operators_trailing_slash', () => {
|
||||
var hash;
|
||||
var narrow;
|
||||
|
||||
hash = '#narrow/stream/devel/topic/algol/';
|
||||
narrow = hashchange.parse_narrow(hash.split('/'));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'stream', operand: 'devel', negated: false},
|
||||
{operator: 'topic', operand: 'algol', negated: false},
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('people_slugs', () => {
|
||||
var operators;
|
||||
var hash;
|
||||
|
||||
@@ -77,6 +77,11 @@ exports.parse_narrow = function (hash) {
|
||||
// but the user might write one.
|
||||
try {
|
||||
var operator = hash_util.decodeHashComponent(hash[i]);
|
||||
// Do not parse further if empty operator encountered.
|
||||
if (operator === '') {
|
||||
break;
|
||||
}
|
||||
|
||||
var operand = hash_util.decode_operand(operator, hash[i+1] || '');
|
||||
var negated = false;
|
||||
if (operator[0] === '-') {
|
||||
|
||||
Reference in New Issue
Block a user