This collapsing doesn't happen with SCRIPT_URL, hence the determination of SCRIPT_NAME from SCRIPT_URL and PATH_INFO needs to be fixed.
A less severe but similar issue can be observed with the "autoexpansion" feature, when we compare the browser `window.location.pathname` (multiple "/"s when browsing within the default repository) with the generated href ("/" collapsed).
Part of #10048.