I have used location from Rotemya's answer like this
import { Location } from '@angular/common';
constructor(public location: Location) { }
But this.location.origin didn't work for me. So I have used this.location.path.name
ngOnInit() {
console.log(this.location.path.name);
}