perf(util): call toLowerCase() only where needed

Closes #1468