From 17efdb516e07d76039be13395fcae7e03b1f75f3 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 10 Dec 2021 00:58:18 +0100 Subject: [PATCH] GitHub Pages: Migrate to `locationType: history` --- tests/dummy/app/app.js | 7 +++++++ tests/dummy/config/environment.js | 1 - tests/dummy/public/404.html | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/dummy/public/404.html diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js index 523bad60..ae5f060a 100644 --- a/tests/dummy/app/app.js +++ b/tests/dummy/app/app.js @@ -3,6 +3,13 @@ import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'dummy/config/environment'; +// see https://www.smashingmagazine.com/2016/08/sghpa-single-page-app-hack-github-pages/ +let redirect = sessionStorage.redirect; +delete sessionStorage.redirect; +if (redirect && redirect !== location.href) { + history.replaceState(null, null, redirect); +} + export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index 5d3bc25f..17d719eb 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -49,7 +49,6 @@ module.exports = function (environment) { if (process.env.DEPLOY_TARGET === 'GitHub Pages') { ENV.rootURL = '/ember-error-route'; - ENV.locationType = 'hash'; } return ENV; diff --git a/tests/dummy/public/404.html b/tests/dummy/public/404.html new file mode 100644 index 00000000..14ef9ad3 --- /dev/null +++ b/tests/dummy/public/404.html @@ -0,0 +1,11 @@ + + + + + + + + +