Move the build_relative_url function into the utils module; fix the non trailing slash case.