mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
util: Kill off rtrim() helper.
I am 99% sure we can rely on trimRight() and trim() being available in all browsers that we support. I verified in FF. This removes the util dependency from both modules touched here.
This commit is contained in:
@@ -39,12 +39,6 @@ run_test('is_pm_recipient', () => {
|
|||||||
assert(!util.is_pm_recipient('unknown@example.com', message));
|
assert(!util.is_pm_recipient('unknown@example.com', message));
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('rtrim', () => {
|
|
||||||
assert.equal(util.rtrim('foo'), 'foo');
|
|
||||||
assert.equal(util.rtrim(' foo'), ' foo');
|
|
||||||
assert.equal(util.rtrim('foo '), 'foo');
|
|
||||||
});
|
|
||||||
|
|
||||||
run_test('lower_bound', () => {
|
run_test('lower_bound', () => {
|
||||||
let arr = [10, 20, 30, 40, 50];
|
let arr = [10, 20, 30, 40, 50];
|
||||||
assert.equal(util.lower_bound(arr, 5), 0);
|
assert.equal(util.lower_bound(arr, 5), 0);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
const util = require("./util");
|
|
||||||
let message_type = false; // 'stream', 'private', or false-y
|
let message_type = false; // 'stream', 'private', or false-y
|
||||||
|
|
||||||
exports.set_message_type = function (msg_type) {
|
exports.set_message_type = function (msg_type) {
|
||||||
@@ -32,7 +31,7 @@ function get_or_set(fieldname, keep_leading_whitespace) {
|
|||||||
if (newval !== undefined) {
|
if (newval !== undefined) {
|
||||||
elem.val(newval);
|
elem.val(newval);
|
||||||
}
|
}
|
||||||
return keep_leading_whitespace ? util.rtrim(oldval) : $.trim(oldval);
|
return keep_leading_whitespace ? oldval.trimRight() : oldval.trim();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
const util = require("./util");
|
|
||||||
// Parsing routine that can be dropped in to message parsing
|
// Parsing routine that can be dropped in to message parsing
|
||||||
// and formats code blocks
|
// and formats code blocks
|
||||||
//
|
//
|
||||||
@@ -116,7 +115,7 @@ exports.process_fenced_code = function (content) {
|
|||||||
if (line === fence) {
|
if (line === fence) {
|
||||||
this.done();
|
this.done();
|
||||||
} else {
|
} else {
|
||||||
lines.push(util.rtrim(line));
|
lines.push(line.trimRight());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -131,10 +131,6 @@ exports.robust_uri_decode = function (str) {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.rtrim = function (str) {
|
|
||||||
return str.replace(/\s+$/, '');
|
|
||||||
};
|
|
||||||
|
|
||||||
// If we can, use a locale-aware sorter. However, if the browser
|
// If we can, use a locale-aware sorter. However, if the browser
|
||||||
// doesn't support the ECMAScript Internationalization API
|
// doesn't support the ECMAScript Internationalization API
|
||||||
// Specification, do a dumb string comparison because
|
// Specification, do a dumb string comparison because
|
||||||
|
|||||||
Reference in New Issue
Block a user