Just a shot in the dark, not that familiar with this whole topic, but due to your urgency, just pointing out that there is a function wp_parse_url() (see wp_parse_url() | Function | WordPress Developer Resources) that seems to solve a bug in PHP’s parse_url that you are using. Hope that helps.
The problem was that the yoast sitemap did not change the links of the “base” pages of each post type with the filter. And when I disabled the Yoast sitemap, I could not reach the core sitemap either. I found out now after a little research that if you disable the yoast sitemap, yoast also disables the core sitemap.
So I added this filter to the functions.php to activate it again:
And with that done, the core sitemap works, with the yoast sitemap deactivated. And the solution that @SantosGuillamot provided works for all the links in the core sitemap.