Fix URL scheme rewrite

The regex magic messes up the url. E.g. "https://null.org" would be
rewritten to "wss://.org".