4 ms·
I find that branchiness (and mutation of the variable) harder to follow. Personally, I’d just take “parse, don’t validate” to its logical conclusion and go for:
by wolfgang42 5y ago
I find that branchiness (and mutation of the variable) harder to follow. Personally, I’d just take “parse, don’t validate” to its logical conclusion and go for:
const parseUrl = url => validateUrl(url) ? url : null;
return parseUrl(url) || parseUrl('http://'+url) || null;