thanks for the comment, spent some time tidying up and ended up also implementing the async lookup for when regex won't work.
i'll do a write-up in the morning and share it to get some feedback. once I started digging into this feature I found lots of little edge cases and considered several ways of implementing it, so i'll be curious what you think of the code