Regex is not much readable when there are more strings.
const isLocal = domain && /^(localhost|127\.0\.0\.1)$/.test(domain);
This is for me better solution:
const localDomains = [ 'localhost', '127.0.0.1' ];
const isLocal = domain && localDomains.includes(domain);
This is also a very nice solution. I’ll add it to the tips! Thank you. I know that for some people, regex can be a eyesore. But there is beauty in its power.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.