Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

ssatz/Angular5-Preserve-Trailing-Slash

Repository files navigation

Preserve trailing slash in Angular5

To work with Angular Universal , Copy the main.ts Location strategy code to main.server.ts


const __stripTrailingSlash = (Location as any).stripTrailingSlash;
(Location as any).stripTrailingSlash = function _stripTrailingSlash(url: string): string {
  const queryString$ = url.match(/([^?]*)?(.*)/);
  if (queryString$[2].length > 0) {
    return /[^\/]\/$/.test(queryString$[1]) ? queryString$[1] + '.' + queryString$[2] : __stripTrailingSlash(url);
  }
  return /[^\/]\/$/.test(url) ? url + '.' : __stripTrailingSlash(url);
};

Credits @gdi2290

About

Angular5 Preserve Trailing Slash

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published