Probably want to start this with `if (!str) { return ''; }` as `null` and `undefined` will give wonky results.