Fixed trailing slash removal code.

Change-Id: I152dcec5cc8f4c417e3503f4b8fd3fdd8bc4fda5