This regex is wrong. I think you want `/^https:\/\/([^:/]+)(?::(\d+))?/`