Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix @typescript-eslint/prefer-regexp-exec.

Anders Kaseorg8196c4f63de3
diff --git a/web/src/copy_and_paste.ts b/web/src/copy_and_paste.ts
index 80cc2315e1b..48d81883673 100644
--- a/web/src/copy_and_paste.ts
+++ b/web/src/copy_and_paste.ts
@@ -567,7 +567,7 @@ export function paste_handler_converter(paste_html: string): string {
const className = codeElement.getAttribute("class") ?? "";
const language = node.parentElement?.classList.contains("zulip-code-block")
? (node.closest<HTMLElement>(".codehilite")?.dataset?.codeLanguage ?? "")
- : (className.match(/language-(\S+)/) ?? [null, ""])[1];
+ : (/language-(\S+)/.exec(className) ?? [null, ""])[1];
assert(options.fence !== undefined);
const fenceChar = options.fence.charAt(0);
diff --git a/web/src/input_pill.ts b/web/src/input_pill.ts
index 640f8dd47d0..faae34c0618 100644
--- a/web/src/input_pill.ts
+++ b/web/src/input_pill.ts
@@ -170,7 +170,7 @@ export function create<ItemType extends {type: string}>(
if (value.length === 0) {
return true;
}
- if (store.split_text_on_comma && value.match(",")) {
+ if (store.split_text_on_comma && value.includes(",")) {
funcs.insertManyPills(value);
return false;
}
diff --git a/web/src/lightbox.ts b/web/src/lightbox.ts
index 4591389d356..4f57227fb49 100644
--- a/web/src/lightbox.ts
+++ b/web/src/lightbox.ts
@@ -397,7 +397,7 @@ export function build_open_media_function(
const payload = parse_media_data(util.the($media));
assert(payload !== undefined);
- if (payload.type.match("-video")) {
+ if (payload.type.includes("-video")) {
display_video(payload);
} else if (payload.type === "image") {
display_image(payload);
@@ -509,7 +509,7 @@ export function parse_media_data(media: HTMLMediaElement | HTMLImageElement): Pa
let original_width_px;
let original_height_px;
if (original_dimensions) {
- const found = original_dimensions.match(/^(\d+)x(\d+)$/);
+ const found = /^(\d+)x(\d+)$/.exec(original_dimensions);
if (found) {
original_width_px = Number(found[1]);
original_height_px = Number(found[2]);
diff --git a/web/src/util.ts b/web/src/util.ts
index daf55c007af..9c1b604fe4b 100644
--- a/web/src/util.ts
+++ b/web/src/util.ts
@@ -198,8 +198,8 @@ export function find_stream_wildcard_mentions(message_content: string): string |
// We cannot use the exact same regex as the server side uses (in zerver/lib/mention.py)
// because Safari < 16.4 does not support look-behind assertions. Reframe the lookbehind of a
// negative character class as a start-of-string or positive character class.
- const mention = message_content.match(
- /(?:^|[\s"'(/<[{])(@\*{2}(all|everyone|stream|channel)\*{2})/,
+ const mention = /(?:^|[\s"'(/<[{])(@\*{2}(all|everyone|stream|channel)\*{2})/.exec(
+ message_content,
);
if (mention === null) {
return null;