To simplify the function without the need to manually juggle indices, I refactored it in such a way that it takes the nearest phone number to be updated, updates it, reassigns a "new" string and repeat until there are no longer any numbers detected. A threshold value was also set to minimise the risk of an infinite being introduced for whatever reason (e.g. it couldn't format stuff properly and a number always remains detected)
Added unit test for
stripPhone
utility function.While working on unit tests I discovered a test case that wasn't working as documented in Issue #230.
Before refactoring the function, I performed some validations to make sure the
findPhoneNumbersInText
function was working as intended.yielded
Hence, there is no issue.
To simplify the function without the need to manually juggle indices, I refactored it in such a way that it takes the nearest phone number to be updated, updates it, reassigns a "new" string and repeat until there are no longer any numbers detected. A threshold value was also set to minimise the risk of an infinite being introduced for whatever reason (e.g. it couldn't format stuff properly and a number always remains detected)