fix getCommonPrefix and getCommonPostfix to handle a single string