Skip to content

Commit

Permalink
fix: input validate for online debug url (#1164)
Browse files Browse the repository at this point in the history
* fix: input validate for online debug url

* fix: update regular expression

Co-authored-by: 琚致远 <juzhiyuan@apache.org>
  • Loading branch information
liuxiran and juzhiyuan authored Dec 30, 2020
1 parent a343171 commit 8375962
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion web/src/pages/Route/components/DebugViews/DebugDrawView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ const DebugDrawView: React.FC<RouteModule.DebugDrawProps> = (props) => {
};

const handleDebug = (url: string) => {
if (url === '') {
/* eslint-disable no-useless-escape */
const urlReg = /^(?=^.{3,255}$)(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w*)*(\.\w+)*([\?&]\w+=\w*)*$/;
if (!urlReg.test(url)) {
notification.warning({
message: formatMessage({ id: 'page.route.input.placeholder.requestUrl' }),
});
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Route/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {

'page.route.input.placeholder.parameterNameHttpHeader': 'Request header name, for example: HOST',
'page.route.input.placeholder.parameterNameRequestParameter': 'Parameter name, for example: id',
'page.route.input.placeholder.requestUrl': 'please input the request URL',
'page.route.input.placeholder.requestUrl': 'please input the valid request URL',
'page.route.input.placeholder.paramKey': 'Param Key',
'page.route.input.placeholder.paramValue': 'Param Value',

Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Route/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
'page.route.input.placeholder.parameterNameHttpHeader': '请求头键名,例如:HOST',
'page.route.input.placeholder.parameterNameRequestParameter': '参数名称,例如:id',
'page.route.input.placeholder.redirectCustom': '例如:/foo/index.html',
'page.route.input.placeholder.requestUrl': '请输入请求地址',
'page.route.input.placeholder.requestUrl': '请输入合法的请求地址',
'page.route.input.placeholder.paramKey': '参数名称',
'page.route.input.placeholder.paramValue': '参数值',
// form
Expand Down

0 comments on commit 8375962

Please sign in to comment.