|
|
|
|
|
by wolfgang42
1732 days 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;
|
|