Skip to content
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

Merged
merged 2 commits into from
Mar 15, 2021
Merged

Checking if 3000 port is running #30

merged 2 commits into from
Mar 15, 2021

Conversation

shailee-m
Copy link
Member

@shailee-m shailee-m commented Mar 13, 2021

Closes #29

Checking if the 3000 port is running before connecting. If yes, uses that as baseUrl.

@shailee-m shailee-m requested a review from brylie March 13, 2021 20:14
@shailee-m
Copy link
Member Author

@brylie can you give me push rights to https://github.com/GeriLife/wellbeing-deploy ?

@brylie
Copy link
Member

brylie commented Mar 14, 2021

@shailee-m you should now be able to open a branch in wellbeing-deploy repo

frontend/src/boot/env-parser.js Outdated Show resolved Hide resolved
Comment on lines 10 to 23
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;
}
Copy link
Member

@brylie brylie Mar 14, 2021

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:

Suggested change
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;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

frontend/yarn.lock Outdated Show resolved Hide resolved
@@ -7,6 +7,20 @@ const axiosInstance = axios.create({
baseURL: process.env.BASE_URL
});
const _appendSubdomain = (domain, subdomain) => {
Copy link
Member

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.

@shailee-m shailee-m requested a review from brylie March 15, 2021 16:57
@brylie brylie merged commit acf6f0d into develop Mar 15, 2021
@brylie brylie deleted the 29-default-port branch March 15, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants