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(#993): add character check for tag sulg name
haitao(lj)7d778bfd769c
diff --git a/ui/src/components/Questions/index.tsx b/ui/src/components/Questions/index.tsxindex 61b03303..987727bc 100644--- a/ui/src/components/Questions/index.tsx+++ b/ui/src/components/Questions/index.tsx@@ -100,15 +100,6 @@ const QuestionList: FC<Props> = ({ source }) => {}const { data: listData, isLoading } = useQuestionList(reqParams);const count = listData?.count || 0;- // const onOrderChange = (evt, order) => {- // evt.preventDefault();- // if (order === curOrder) {- // return;- // }- // urlSearchParams.set('page', '1');- // urlSearchParams.set('order', order);- // setUrlSearchParams(urlSearchParams);- // };return (<div>diff --git a/ui/src/hooks/useTagModal/index.tsx b/ui/src/hooks/useTagModal/index.tsxindex bbb5aff4..d4fbef7e 100644--- a/ui/src/hooks/useTagModal/index.tsx+++ b/ui/src/hooks/useTagModal/index.tsx@@ -56,7 +56,7 @@ const useTagModal = (props: IProps = {}) => {} else if (displayName.value.length > MAX_LENGTH) {bol = false;formData.displayName = {- value: '',+ value: displayName.value,isInvalid: true,errorMsg: t('form.fields.display_name.msg.range'),};@@ -67,6 +67,7 @@ const useTagModal = (props: IProps = {}) => {errorMsg: '',};}+if (!slugName.value) {bol = false;formData.slugName = {@@ -77,10 +78,17 @@ const useTagModal = (props: IProps = {}) => {} else if (slugName.value.length > MAX_LENGTH) {bol = false;formData.slugName = {- value: '',+ value: slugName.value,isInvalid: true,errorMsg: t('form.fields.slug_name.msg.range'),};+ } else if (/[^a-z0-9+#\-.]/.test(slugName.value)) {+ bol = false;+ formData.slugName = {+ value: slugName.value,+ isInvalid: true,+ errorMsg: t('form.fields.slug_name.msg.character'),+ };} else {formData.slugName = {value: slugName.value,diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.jsonindex 9f98d9ec..76b92414 100644--- a/ui/src/i18n/locales/en.json+++ b/ui/src/i18n/locales/en.json@@ -221,7 +221,8 @@"description": "Spaces are not allowed, please use '-' instead.","msg": {"empty": "Please enter a name for the tag.",- "range": "URL slug up to 35 characters"+ "range": "URL slug up to 35 characters",+ "character": "must use the character set a-z 0-9 + # - ."}},"description": {