title: How to add trailing slash in URL in angular 7 without 404 issue on refresh?
body: <p>I am adding trailing slash in url end in Angular 7, below is the code i found to add trailing slash in angular and its working fine. But when i refresh page it redirect me to 404 component. </p>
  
  <pre><code>import {Location, PathLocationStrategy} from '@angular/common';
  const _orig_prepareExternalUrl = 
  PathLocationStrategy.prototype.prepareExternalUrl;
  
  PathLocationStrategy.prototype.prepareExternalUrl = function(internal) {
  const url = _orig_prepareExternalUrl.call(this, internal);
  
  if (url === '') {
  return url;
  }
  
  console.log('For ' + internal + ' we generated ' + url);
  if (url.endsWith('.html')) {
    return url;
  }
  
  if (url.endsWith('/')) {
  return url;
  }
  
  
  return url + '/';
  
  };
  
  Location.stripTrailingSlash = function (url) {
  const /** @type {?} */ match = url.match(/#|\?|$/);
  const /** @type {?} */ pathEndIdx = match &amp;&amp; match.index || url.length;
  const /** @type {?} */ droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
  const first = url.slice(0, droppedSlashIdx);
  const last = url.slice(pathEndIdx);
  
  if (first.endsWith('.html')) {
      return first + last;
  }
  
  return first + '/' + last;
  
  };
  </code></pre>
  
  <p>I expect to show same component on which i am with trailing slash without 404.</p>