[FORWARD PORT] LPS-50299 remove leading an trailing '-' from friendly URLs

This is a forward port of https://github.com/sergiogonzalez/liferay-portal-ee/pull/44