Fix trailing slashes in generated URLs

Some URLs were being generated with extra trailing URLs when there was
no object id.
Merge branch 'fix-trailing-slashes-before-query-parameters' into develop