Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(Questions): No more `isAnswerId` matching for short ids

haitaoo3071c99a2361
diff --git a/ui/src/common/pattern.ts b/ui/src/common/pattern.ts
index 4a7f7a5f..72086a68 100644
--- a/ui/src/common/pattern.ts
+++ b/ui/src/common/pattern.ts
@@ -4,7 +4,6 @@ const pattern = {
emoji: emojiRegex(),
email:
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
- isAnswerId: /^1002\d{13}$/,
};
export default pattern;
diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx
index db3c8ebd..063a295e 100644
--- a/ui/src/pages/Questions/Detail/index.tsx
+++ b/ui/src/pages/Questions/Detail/index.tsx
@@ -8,7 +8,6 @@ import {
} from 'react-router-dom';
import { useTranslation } from 'react-i18next';
-import Pattern from '@/common/pattern';
import { Pagination } from '@/components';
import { loggedUserInfoStore, toastStore } from '@/stores';
import { scrollToElementTop } from '@/utils';
@@ -40,7 +39,7 @@ const Index = () => {
* Note: Compatible with Permalink
*/
let { aid = '' } = useParams();
- if (!aid && Pattern.isAnswerId.test(slugPermalink)) {
+ if (!aid && slugPermalink) {
aid = slugPermalink;
}
@@ -76,9 +75,10 @@ const Index = () => {
page: 1,
page_size: 999,
});
+
if (res) {
res.list = res.list?.filter((v) => {
- // delete answers pnly show to author and admin and has searchparams aid
+ // delete answers only show to author and admin and has search params aid
if (v.status === 10) {
if (
(v?.user_info.username === userInfo?.username || isAdmin) &&