1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-08 15:25:22 +02:00

fix(edge): allow more options for url [EE-2975] (#6781)

This commit is contained in:
Chaim Lev-Ari 2022-05-05 10:03:24 +03:00 committed by GitHub
parent d4c2ad4a57
commit c732ca2d2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -23,11 +23,20 @@ const validation = yup.object({
EdgePortainerUrl: yup
.string()
.test(
'not-local',
'Cannot use localhost as environment URL',
(value) => !value?.includes('localhost')
'url',
'URL should be a valid URI and cannot include localhost',
(value) => {
if (!value) {
return false;
}
try {
const url = new URL(value);
return !!url.hostname && url.hostname !== 'localhost';
} catch {
return false;
}
}
)
.url('URL should be a valid URI')
.required('URL is required'),
});