You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2021/04/20 03:47:43 UTC

[apisix-dashboard] 01/02: fix: update FE regex according to schema_def (#238)

This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch fix-minor-issues
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git

commit 513d9b00984ba87712447d8494236a3c8ded1051
Author: 琚致远 <ju...@apache.org>
AuthorDate: Tue Apr 20 11:40:10 2021 +0800

    fix: update FE regex according to schema_def (#238)
---
 web/src/components/Plugin/UI/referer-restriction.tsx         | 4 +++-
 web/src/components/Upstream/components/Nodes.tsx             | 6 +++---
 web/src/components/Upstream/components/active-check/Host.tsx | 2 +-
 web/src/pages/Route/components/Step1/RequestConfigView.tsx   | 8 +-------
 web/src/pages/Route/locales/en-US.ts                         | 5 +----
 web/src/pages/Route/locales/zh-CN.ts                         | 4 +---
 6 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/web/src/components/Plugin/UI/referer-restriction.tsx b/web/src/components/Plugin/UI/referer-restriction.tsx
index 971302b..0e527a1 100644
--- a/web/src/components/Plugin/UI/referer-restriction.tsx
+++ b/web/src/components/Plugin/UI/referer-restriction.tsx
@@ -73,7 +73,9 @@ const RefererRestriction: React.FC<Props> = ({ form }) => {
                         noStyle
                         required
                         rules={[{
-                          message: "",
+                          message: formatMessage({
+                            id: 'page.route.form.itemRulesPatternMessage.domain',
+                          }),
                           pattern: new RegExp(/^\*?[0-9a-zA-Z-._]+$/, 'g')
                         }, {
                           required: true,
diff --git a/web/src/components/Upstream/components/Nodes.tsx b/web/src/components/Upstream/components/Nodes.tsx
index 92bfcda..8379c8a 100644
--- a/web/src/components/Upstream/components/Nodes.tsx
+++ b/web/src/components/Upstream/components/Nodes.tsx
@@ -48,12 +48,12 @@ const Component: React.FC<Props> = ({ readonly }) => {
                       },
                       {
                         pattern: new RegExp(
-                          /(^([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])(\.(25[0-5]|1\d{2}|2[0-4]\d|[1-9]?\d)){3}$|^(?![0-9.]+$)([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+){0,}$)/,
+                          /^\*?[0-9a-zA-Z-._]+$/,
                           'g',
                         ),
                         message: formatMessage({
-                          id: 'page.upstream.step.valid.domain.name.or.ip',
-                        })
+                          id: 'page.route.form.itemRulesPatternMessage.domain',
+                        }),
                       },
                     ]}
                   >
diff --git a/web/src/components/Upstream/components/active-check/Host.tsx b/web/src/components/Upstream/components/active-check/Host.tsx
index 148d60a..87e68a3 100644
--- a/web/src/components/Upstream/components/active-check/Host.tsx
+++ b/web/src/components/Upstream/components/active-check/Host.tsx
@@ -35,7 +35,7 @@ const Component: React.FC<Props> = ({ readonly }) => {
         rules={[
           {
             pattern: new RegExp(
-              /^\\*?[0-9a-zA-Z-._]+$/,
+              /^\*?[0-9a-zA-Z-._]+$/,
               'g',
             ),
             message: formatMessage({ id: 'component.upstream.fields.checks.active.host.scope' }),
diff --git a/web/src/pages/Route/components/Step1/RequestConfigView.tsx b/web/src/pages/Route/components/Step1/RequestConfigView.tsx
index 05ce260..2c7bf89 100644
--- a/web/src/pages/Route/components/Step1/RequestConfigView.tsx
+++ b/web/src/pages/Route/components/Step1/RequestConfigView.tsx
@@ -58,7 +58,7 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
                       rules={[
                         {
                           // NOTE: https://github.com/apache/apisix/blob/master/apisix/schema_def.lua#L40
-                          pattern: new RegExp(/^\\*?[0-9a-zA-Z-._]+$/, 'g'),
+                          pattern: new RegExp(/^\*?[0-9a-zA-Z-._]+$/, 'g'),
                           message: formatMessage({
                             id: 'page.route.form.itemRulesPatternMessage.domain',
                           }),
@@ -129,12 +129,6 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
                           whitespace: true,
                           message: formatMessage({ id: "page.route.configuration.path.rules.required.description" }),
                         },
-                        {
-                          pattern: new RegExp(/^\/[a-zA-Z0-9\-._~%!$&'()+,;=:@/]*\*?$/, 'g'),
-                          message: formatMessage({
-                            id: 'page.route.form.itemRulesPatternMessage.path',
-                          }),
-                        },
                       ]}
                       noStyle
                     >
diff --git a/web/src/pages/Route/locales/en-US.ts b/web/src/pages/Route/locales/en-US.ts
index 2609800..ecbffb8 100644
--- a/web/src/pages/Route/locales/en-US.ts
+++ b/web/src/pages/Route/locales/en-US.ts
@@ -75,10 +75,9 @@ export default {
   'page.route.form.itemExtraMessage.domain':
     'Domain Name or IP, support for generic Domain Name, for example: *.test.com',
   'page.route.form.itemRulesPatternMessage.domain':
-    'Only letters, numbers and * are supported. * can only be at the beginning, and only single * is supported',
+    'Only letters, numbers and * are supported, but * needs to be at the beginning.',
   'page.route.form.itemExtraMessage1.path':
     'HTTP Request path, for example: /foo/index.html, supports request path prefix /foo/* ; /* represents all paths',
-  'page.route.form.itemRulesPatternMessage.path': 'Begin with / , and * can only at the end',
   'page.route.form.itemRulesPatternMessage.remoteAddrs':
     'Please enter a valid IP address, for example: 192.168.1.101, 192.168.1.0/24, ::1, fe80::1, fe80::1/64',
   'page.route.form.itemExtraMessage1.remoteAddrs':
@@ -98,8 +97,6 @@ export default {
   'page.route.form.itemLabel.domainNameOrIp': 'Domain Name/IP',
   'page.route.form.itemExtraMessage.domainNameOrIp':
     'When using Domain Name, it will analysis the local: /etc/resolv.conf by default',
-  'page.route.form.itemRulesPatternMessage.domainNameOrIp':
-    'Only letters, numbers and . are supported',
   'page.route.portNumber': 'Port Number',
   'page.route.weight': 'Weight',
   'page.route.radio.staySame': 'Stay The Same',
diff --git a/web/src/pages/Route/locales/zh-CN.ts b/web/src/pages/Route/locales/zh-CN.ts
index 3c134bc..8cc2825 100644
--- a/web/src/pages/Route/locales/zh-CN.ts
+++ b/web/src/pages/Route/locales/zh-CN.ts
@@ -74,10 +74,9 @@ export default {
   'page.route.form.itemLabel.redirectURI': '重定向路径',
   'page.route.form.itemExtraMessage.domain': '路由匹配的域名列表。支持泛域名,如:*.test.com',
   'page.route.form.itemRulesPatternMessage.domain':
-    '仅支持字母、数字和 * ,且 * 只能是在开头,支持单个 * ',
+    '仅支持字母、数字和 *,但 * 需要在开头位置。',
   'page.route.form.itemExtraMessage1.path':
     'HTTP 请求路径,如 /foo/index.html,支持请求路径前缀 /foo/*。/* 代表所有路径',
-  'page.route.form.itemRulesPatternMessage.path': '以 / 开头,且 * 只能在最后',
   'page.route.form.itemExtraMessage1.remoteAddrs':
     '客户端与服务器握手时 IP,即客户端 IP,例如:192.168.1.101,192.168.1.0/24,::1,fe80::1,fe80::1/64',
   'page.route.form.itemRulesPatternMessage.remoteAddrs':
@@ -113,7 +112,6 @@ export default {
 
   'page.route.form.itemLabel.domainNameOrIp': '域名/IP',
   'page.route.form.itemExtraMessage.domainNameOrIp': '使用域名时,默认解析本地:/etc/resolv.conf',
-  'page.route.form.itemRulesPatternMessage.domainNameOrIp': '仅支持字母、数字和 . ',
   'page.route.portNumber': '端口',
   'page.route.weight': '权重',