CSP Errors with S3 configuration when s3_cdn_url has trailing slash

Continuing the discussion from Using Object Storage for Uploads (S3 & Clones):

I’ve got a site I just moved to S3.

All of my assets were giving CSP errors. If I right-click them and open them, they worked fine. I cleared my bunnyCDN cache (but didn’t have any speed-ups configured there).

Finally, I saw a request in the network panel that showed two slashes after the hostname.

I went and changed

 DISCOURSE_CDN_URL: https://pfaffmanager.b-cdn.net/ 

DISCOURSE_CDN_URL: https://pfaffmanager.b-cdn.net

destroyed, and restarted the container and it worked.

Would it be possible to have something chomp a trailing slash?

And then there were the several rebuilds I did before remembering to include the rake s3:upload_assets stanza. It’d be nice if (1) there were a template that did that, perhaps included (commented out) in standalone.yml and web_only.yml. Or better still, it could be included by default and fire only when DISCOURSE_USE_S3 is defined?