-
Notifications
You must be signed in to change notification settings - Fork 134
Improve URL validator to support localhost and local IPs in development #1122
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
base: enext
Are you sure you want to change the base?
Changes from 3 commits
64669b8
6d31cf5
3a7d106
7ac4963
a299055
9caa1fe
a976e8f
0f7b52c
c7fa749
03c756b
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,9 +40,10 @@ export function youtubeid(message) { | |||||||||||||||
| return helpers.withMessage(message, helpers.regex(/^[0-9A-Za-z_-]{5,}$/)) | ||||||||||||||||
| } | ||||||||||||||||
| const relative = helpers.regex(/^\/.*$/) | ||||||||||||||||
| const devurl = helpers.regex(/^http:\/\/localhost.*$/) // vuelidate does not allow localhost | ||||||||||||||||
| // Allow localhost and local IP addresses (with or without port) | ||||||||||||||||
| const localurl = helpers.regex(/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:[0-9]+)?(\/.*)?$/) | ||||||||||||||||
| export function url(message) { | ||||||||||||||||
| return helpers.withMessage(message, (value) => (!helpers.req(value) || _url(value) || relative(value) || (ENV_DEVELOPMENT && devurl(value)))) | ||||||||||||||||
| return helpers.withMessage(message, (value) => (!helpers.req(value) || _url(value) || relative(value) || localurl(value))) | ||||||||||||||||
|
||||||||||||||||
| return helpers.withMessage(message, (value) => (!helpers.req(value) || _url(value) || relative(value) || localurl(value))) | |
| return helpers.withMessage(message, (value) => ( | |
| !helpers.req(value) || | |
| _url(value) || | |
| relative(value) || | |
| (typeof ENV_DEVELOPMENT !== 'undefined' && ENV_DEVELOPMENT === true && localurl(value)) | |
| )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ENV_DEVELOPMENT check expects the webapp to run in dev mode with a hot-reload server, but npm start under the webapp doesn’t work in our setup. So it was blocking valid localhost use.
Also here I am considering that we need localhost support in production for self-hosted and Docker setups.
Uh oh!
There was an error while loading. Please reload this page.