-
Notifications
You must be signed in to change notification settings - Fork 766
Full-stack: Make "Server url" validation conditions consistent across Fleet, update Web Address form validation and submission logic per Fleet best practices (frontend/docs/patterns.md)
#27455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2c04413
880ab3e
5d91eb3
9044315
883400c
00efbad
66567e1
133ba40
2d12dc4
48b09b3
bc033b5
c70141f
3da6c59
05e0c06
7d39817
478820b
9b7a2f4
30ba820
d9e830f
7e48d93
d5ddf5e
312e7b2
96be402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Accept any "http://" or "https://" prefixed Fleet web URL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,13 @@ interface IValidUrl { | |
| url: string; | ||
| /** Validate protocols specified */ | ||
| protocols?: ("http" | "https")[]; | ||
| allowLocalHost?: boolean; | ||
| } | ||
|
|
||
| export default ({ url, protocols }: IValidUrl): boolean => { | ||
| return isURL(url, { protocols }); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't actually validating that the provided url uses one of the provided protocols |
||
| export default ({ url, protocols, allowLocalHost = false }: IValidUrl) => { | ||
| return isURL(url, { | ||
| protocols, | ||
| require_protocol: !!protocols?.length, | ||
| require_tld: !allowLocalHost, | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| const INVALID_SERVER_URL_MESSAGE = `Fleet server address must be a valid “https” or “http” URL.`; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because the frontend actually does validate both the scheme and a valid hostname |
||
|
|
||
| export default INVALID_SERVER_URL_MESSAGE; | ||
Uh oh!
There was an error while loading. Please reload this page.