diff --git a/app/locations/trailing-history.js b/app/locations/trailing-history.js new file mode 100644 index 00000000..ef2eadeb --- /dev/null +++ b/app/locations/trailing-history.js @@ -0,0 +1,16 @@ +import HistoryLocation from '@ember/routing/history-location'; + +/* When using this location type with ember-cli dev server, be sure to + set historySupportMiddleware: true in config/environment.js */ + +export default class extends HistoryLocation { + formatURL() { + let url = super.formatURL(...arguments); + + if (url.includes('#')) { + return url.replace(/([^/])#(.*)/, '$1/#$2'); + } else { + return url.replace(/\/?$/, '/'); + } + } +} diff --git a/config/environment.js b/config/environment.js index 90d4a233..600dc997 100644 --- a/config/environment.js +++ b/config/environment.js @@ -11,7 +11,8 @@ module.exports = function (environment) { environment, rootURL: '/', routerRootURL: '/', - locationType: 'history', + locationType: 'trailing-history', + historySupportMiddleware: true, EmberENV: { EXTEND_PROTOTYPES: false, FEATURES: {