WICKET-5673 Improve BookmarkableMapper and BasicResourceReferenceMapper to not match when the last segment is empty

(cherry picked from commit bfffed1260a37cd6c338c2495a03377c76fe99d8)