From 327ac765df9413da68c1407e88050c1d2c4b351b Mon Sep 17 00:00:00 2001
From: Jun Wu <quark@lihdd.net>
Date: Sat, 1 Apr 2023 03:28:29 -0700
Subject: [PATCH] utils: simplify trimTopic

Also avoid using Array.prototype.at, which does not seem to exist
in the Wexin builtin webview (Android Wexin 8.0.30).
---
 app/utils.ts | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/app/utils.ts b/app/utils.ts
index 64120df4d..1fb3d3166 100644
--- a/app/utils.ts
+++ b/app/utils.ts
@@ -2,15 +2,7 @@ import { showToast } from "./components/ui-lib";
 import Locale from "./locales";
 
 export function trimTopic(topic: string) {
-  const s = topic.split("");
-  let lastChar = s.at(-1); // 获取 s 的最后一个字符
-  let pattern = /[,。!?、,.!?]/; // 定义匹配中文和英文标点符号的正则表达式
-  while (lastChar && pattern.test(lastChar!)) {
-    s.pop();
-    lastChar = s.at(-1);
-  }
-
-  return s.join("");
+  return topic.replace(/[,。!?、,.!?]*$/, "");
 }
 
 export function copyToClipboard(text: string) {