`urlunparse` I think might have more of the corner cases worked out.