trimFromExtraSpaces barfed on 'text' being None. Trying to save the case by first replacing None with an empty string, later filling the empty string with the link contents.