Fix TypeError when updating slug

- added check slug before trim
Merge pull request #3762 from blia/dev

Fixed TypeError when updating slug