-
Notifications
You must be signed in to change notification settings - Fork 0
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
Checking if 3000 port is running #30
Conversation
…uses that as baseUrl
@brylie can you give me push rights to https://github.com/GeriLife/wellbeing-deploy ? |
@shailee-m you should now be able to open a branch in wellbeing-deploy repo |
frontend/src/boot/axios.js
Outdated
const ip = domain.split("://")[1] | ||
? domain.split("://")[1].split(":") | ||
? domain.split("://")[1].split(":")[0] | ||
: null | ||
: null; | ||
|
||
//skip adding sub-domain to ip | ||
if ( | ||
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( | ||
ip | ||
) | ||
) { | ||
return domain; | ||
} |
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.
Please try to keep code very simple.
In this case, I'm in favor of simplifying this code in a slightly imperfect manner along these lines:
const ip = domain.split("://")[1] | |
? domain.split("://")[1].split(":") | |
? domain.split("://")[1].split(":")[0] | |
: null | |
: null; | |
//skip adding sub-domain to ip | |
if ( | |
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( | |
ip | |
) | |
) { | |
return domain; | |
} | |
// We grab the hostname (including port since port won't affect the regexp) | |
const hostname = domain.split("://")[1]; | |
// a domain name contains at least one letter (in all of the cases I can think of) | |
const hostnameIsDomain = hostname.match(/[a-z]/i); | |
// skip adding sub-domain to IP | |
if (!hostnameIsDomain) { | |
return domain; | |
} |
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.
done.
@@ -7,6 +7,20 @@ const axiosInstance = axios.create({ | |||
baseURL: process.env.BASE_URL | |||
}); | |||
const _appendSubdomain = (domain, subdomain) => { |
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.
When possible, try not to overload functions with a lot of different steps. Ideally, a function would do only one thing and the name of the function would describe the one thing it does.
Closes #29
Checking if the 3000 port is running before connecting. If yes, uses that as baseUrl.