mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
refactor: Rename set_realm_filters().
This name was misleading, because we weren't actually setting realm_filters (that's what `page_params.realm_filters = realm_filters` is for); we were instead updating our realm filter rules.
This commit is contained in:
@@ -19,7 +19,7 @@ set_global('echo', {
|
||||
});
|
||||
|
||||
set_global('markdown', {
|
||||
set_realm_filters: noop,
|
||||
update_realm_filter_rules: noop,
|
||||
});
|
||||
|
||||
set_global('notifications', {
|
||||
|
||||
@@ -570,19 +570,19 @@ run_test('backend_only_realm_filters', () => {
|
||||
|
||||
run_test('python_to_js_filter', () => {
|
||||
// The only way to reach python_to_js_filter is indirectly, hence the call
|
||||
// to set_realm_filters.
|
||||
markdown.set_realm_filters([['/a(?im)a/g'], ['/a(?L)a/g']]);
|
||||
// to update_realm_filter_rules.
|
||||
markdown.update_realm_filter_rules([['/a(?im)a/g'], ['/a(?L)a/g']]);
|
||||
let actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
let expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
// Test case with multiple replacements.
|
||||
markdown.set_realm_filters([['#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)', 'http://google.com']]);
|
||||
markdown.update_realm_filter_rules([['#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)', 'http://google.com']]);
|
||||
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
expected_value = [/#cf([0-9]+)([A-Z][0-9A-Z]*)(?![\w])/g];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
// Test incorrect syntax.
|
||||
blueslip.set_test_data('error', 'python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group');
|
||||
markdown.set_realm_filters([['!@#@(!#&((!&(@#(', 'http://google.com']]);
|
||||
markdown.update_realm_filter_rules([['!@#@(!#&((!&(@#(', 'http://google.com']]);
|
||||
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
expected_value = [];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
|
||||
@@ -27,7 +27,7 @@ set_global('echo', {
|
||||
process_from_server: function (messages) {
|
||||
return messages;
|
||||
},
|
||||
set_realm_filters: noop,
|
||||
update_realm_filter_rules: noop,
|
||||
});
|
||||
set_global('ui_report', {
|
||||
hide_error: function () { return false; },
|
||||
|
||||
@@ -357,7 +357,7 @@ function python_to_js_filter(pattern, url) {
|
||||
return [final_regex, url];
|
||||
}
|
||||
|
||||
exports.set_realm_filters = function (realm_filters) {
|
||||
exports.update_realm_filter_rules = function (realm_filters) {
|
||||
// Update the marked parser with our particular set of realm filters
|
||||
realm_filter_map.clear();
|
||||
realm_filter_list = [];
|
||||
@@ -446,7 +446,7 @@ exports.initialize = function () {
|
||||
// Disable autolink as (a) it is not used in our backend and (b) it interferes with @mentions
|
||||
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'autolink');
|
||||
|
||||
exports.set_realm_filters(page_params.realm_filters);
|
||||
exports.update_realm_filter_rules(page_params.realm_filters);
|
||||
|
||||
// Tell our fenced code preprocessor how to insert arbitrary
|
||||
// HTML into the output. This generated HTML is safe to not escape
|
||||
|
||||
@@ -220,7 +220,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
||||
|
||||
case 'realm_filters':
|
||||
page_params.realm_filters = event.realm_filters;
|
||||
markdown.set_realm_filters(page_params.realm_filters);
|
||||
markdown.update_realm_filter_rules(page_params.realm_filters);
|
||||
settings_linkifiers.populate_filters(page_params.realm_filters);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user