You can use window.location.href or .location instead of using this combination of protocol and host and string manipulation. Depending on your usecase.