Skip to content

Commit ac80b75

Browse files
authored
Validate WebProxy setting (#529)
1 parent 1d605c8 commit ac80b75

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/schema.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ export default {
128128
label: 'WebProxy',
129129
field: 'WebProxy',
130130
placeholder: '',
131-
type: 'InputText'
131+
type: 'InputText',
132+
validator: Validators.url
132133
},
133134
{
134135
label: 'WebProxyPassword',

src/validators.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,24 @@ export default {
126126

127127
return err;
128128
},
129+
url(value, schema) {
130+
const emptyError = checkEmpty(value, schema.required);
131+
if (!isNil(emptyError)) return emptyError;
132+
133+
const err = [];
134+
135+
if (!isString(value)) {
136+
err.push('This is not a text!');
137+
} else {
138+
try {
139+
new URL(value);
140+
} catch {
141+
err.push('This is not a valid URL!');
142+
}
143+
}
144+
145+
return err;
146+
},
129147
tradeToken: limitedString(8, 8),
130148
byte: limitedNumber(0, 255),
131149
ushort: limitedNumber(0, 65535),

0 commit comments

Comments
 (0)