Also factor out common parts in querystring and url. Backport-of: https://github.com/nodejs/node/pull/11161