-
Notifications
You must be signed in to change notification settings - Fork 25
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
login-modal.jsx: Add regex for localhost IPs #182
base: master
Are you sure you want to change the base?
Conversation
Add regex `/^127|^0/` to check for localhost Closes coala#179
@@ -42,7 +42,7 @@ class Login extends Component { | |||
let tld = hostname.split('.').slice(-2).join('.'); | |||
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; |
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.
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
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.
Oh right!
How about this constraint starts with 127 or 0 and ends with a number [0-9]
hostname.match(/(^127|^0)?([0-9]$)/)
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.
Or, I could split the hostname on .
and check if the last index is a digit: hostname.split('.').pop().match(/[0-9]/)
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.
Hmm, why not just check if hostname exactly matches 127.0.0.1
or 0.0.0.0
?
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.
I thought I'll handle cases of 127.x.x.x
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.
@li-boxuan So should I just check for 127.0.0.1
and 0.0.0.0
?
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.
I think so, unless there is any other exception such that you have to use regex to match.
@bhawesh96 Are you still working on this? |
No, I'm not. Please take it forward |
@bhawesh96 this is your task. Please finish it. |
Add regex
/^127|^0/
to check for localhostCloses #179