Skip to content

Comments

login-modal.jsx: Add regex for localhost IPs#182

Open
bhawesh96 wants to merge 1 commit intocoala:masterfrom
bhawesh96:prefill
Open

login-modal.jsx: Add regex for localhost IPs#182
bhawesh96 wants to merge 1 commit intocoala:masterfrom
bhawesh96:prefill

Conversation

@bhawesh96
Copy link
Member

Add regex /^127|^0/ to check for localhost

Closes #179

Add regex `/^127|^0/` to check for localhost

Closes coala#179
if (tld == 'github.io') return null;
if (tld == 'netlify.com') return null;
if (tld == 'localhost') return null;
if (tld == 'localhost' || hostname.match(/^127|^0/)) return null;
Copy link
Member

Choose a reason for hiding this comment

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

Looks fine, but not ideal. What if the website address starts from 127 or 0? e.g. 127.com, or even 127.0.0.1.com

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh right!
How about this constraint starts with 127 or 0 and ends with a number [0-9]
hostname.match(/(^127|^0)?([0-9]$)/)

Copy link
Member Author

Choose a reason for hiding this comment

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

Or, I could split the hostname on . and check if the last index is a digit: hostname.split('.').pop().match(/[0-9]/)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, why not just check if hostname exactly matches 127.0.0.1 or 0.0.0.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought I'll handle cases of 127.x.x.x

Copy link
Member Author

Choose a reason for hiding this comment

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

@li-boxuan So should I just check for 127.0.0.1 and 0.0.0.0?

Copy link
Member

Choose a reason for hiding this comment

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

I think so, unless there is any other exception such that you have to use regex to match.

@123vivekr
Copy link
Member

@bhawesh96 Are you still working on this?

@bhawesh96
Copy link
Member Author

No, I'm not. Please take it forward

@jayvdb
Copy link
Member

jayvdb commented Feb 3, 2019

@bhawesh96 this is your task. Please finish it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants