Added the trim function to prevent bad urls from creating categories.