Skip to content

Commit

Permalink
Add the trailing-history location locally with support for query params
Browse files Browse the repository at this point in the history
until empress/guidemaker#117 is merged and
released
  • Loading branch information
kategengler committed Dec 17, 2024
1 parent 34d3a95 commit 2d3ce8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/locations/trailing-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* TODO: Remove this after the upstream PR to allow query params with the trailing history location is merged
* https://github.com/empress/guidemaker/pull/117
*/

/* eslint-disable ember/no-classic-classes, prettier/prettier */
import HistoryLocation from '@ember/routing/history-location';

export default HistoryLocation.extend({
formatURL() {
let url = this._super(...arguments);
return formatURL(url);
},
});

export function formatURL(url) {
let modifiedURL = new URL(url, 'http://example.com');
modifiedURL.pathname += '/';
return `${modifiedURL.pathname}${modifiedURL.search}${modifiedURL.hash}`;
}
2 changes: 1 addition & 1 deletion app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class ApplicationRoute extends GuideMakerApp {
model(params, ...rest) {
let { feature_flags } = params;
let overrides = Object.fromEntries(
feature_flags?.split(',').map((flag) => [flag, true]) ?? []
feature_flags?.split(',').map((flag) => [flag, true]) ?? [],
);
this.features.setupFeatures(Object.assign({}, FEATURES, overrides));
return super.model(params, ...rest);
Expand Down

0 comments on commit 2d3ce8d

Please sign in to comment.