mirror of https://github.com/portainer/portainer
fix(edge): allow more options for url [EE-2975] (#6781)
parent
d4c2ad4a57
commit
c732ca2d2f
|
@ -19,6 +19,10 @@ func ParseHostForEdge(portainerURL string) (string, error) {
|
|||
portainerHost = parsedURL.Host
|
||||
}
|
||||
|
||||
if portainerHost == "" {
|
||||
return "", errors.New("hostname cannot be empty")
|
||||
}
|
||||
|
||||
if portainerHost == "localhost" {
|
||||
return "", errors.New("cannot use localhost as environment URL")
|
||||
}
|
||||
|
|
|
@ -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'),
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue