String prepareExternalUrl(String url)

Given a string representing a URL, returns the platform-specific external URL path. If the given URL doesn't begin with a leading slash ('/'), this method adds one before normalizing. This method will also add a hash if HashLocationStrategy is used, or the APP_BASE_HREF if the PathLocationStrategy is in use.

Source

String prepareExternalUrl(String url) {
  if (url.length > 0 && !url.startsWith("/")) {
    url = "/" + url;
  }
  return this.platformStrategy.prepareExternalUrl(url);
}