title: How to use pathlocationstrategy in angular 5 to set base href or APP_BASE_HREF?
body: <p>Below is the code snippet:</p>
  
  <p>import {
          Router
      } from "@angular/router";
      import {
          HttpClient
      } from "@angular/common/http";
      import {
          environment
      } from "../../environments/environment";
      import {
          Location,
          LocationStrategy,
          PathLocationStrategy
      } from '@angular/common';</p>
  
  <pre><code>@Injectable()
  export class CommonServicesService {
      PathLocation: Location;
      referralCode: any = localStorage.getItem('referenceCode');
  
      constructor(
          location: Location,
      ) {
          this.PathLocation = location;
      }
  
      redirectAfterSuccessfulLogin() {
          if (localStorage.getItem("redirectUrl")) {
              let url = localStorage.getItem("redirectUrl");
              localStorage.removeItem("redirectUrl");
              this.PathLocation.prepareExternalUrl("'/'+this.referralCode"); //is this the correct way?
              console.log(this.PathLocation);
              this.router.navigate([url]);
          } else {
              this.PathLocation.prepareExternalUrl("'/'+this.referralCode");
              console.log(this.PathLocation);
              this.router.navigate(["/"]);
          }
      }
  }
  </code></pre>