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
|
portainerHost = parsedURL.Host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if portainerHost == "" {
|
||||||
|
return "", errors.New("hostname cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
if portainerHost == "localhost" {
|
if portainerHost == "localhost" {
|
||||||
return "", errors.New("cannot use localhost as environment URL")
|
return "", errors.New("cannot use localhost as environment URL")
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,20 @@ const validation = yup.object({
|
||||||
EdgePortainerUrl: yup
|
EdgePortainerUrl: yup
|
||||||
.string()
|
.string()
|
||||||
.test(
|
.test(
|
||||||
'not-local',
|
'url',
|
||||||
'Cannot use localhost as environment URL',
|
'URL should be a valid URI and cannot include localhost',
|
||||||
(value) => !value?.includes('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'),
|
.required('URL is required'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue