It looks like this was a typo in the original code, but I'm wondering... in what case is the suffixPos check actually needed?  That is, when would we get prefixPos !== null but suffixPos === null?