If the URL format changed without you doing anything, my assumption would be that your server automatically updates Discourse and this was the trigger but I wouldn’t expect the URL comparison you used to be a problem. Unless you’re displaying that URL to users for them to be able to copy, it should work as-is.
A URL beginning “//” uses the same scheme as the document referencing it, i.e. if you successfully visit the page over HTTP, it’s equivalent to “http://”. If you visit the page over HTTPS, it’s equivalent to “https://”