login-modal.jsx: Add regex for localhost IPs#182
login-modal.jsx: Add regex for localhost IPs#182bhawesh96 wants to merge 1 commit intocoala:masterfrom
Conversation
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; |
There was a problem hiding this comment.
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.
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.
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.
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.
I thought I'll handle cases of 127.x.x.x
There was a problem hiding this comment.
@li-boxuan So should I just check for 127.0.0.1 and 0.0.0.0?
There was a problem hiding this comment.
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