Skip to content

Commit 2d3ce8d

Browse files
committed
Add the trailing-history location locally with support for query params
until empress/guidemaker#117 is merged and released
1 parent 34d3a95 commit 2d3ce8d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

app/locations/trailing-history.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* TODO: Remove this after the upstream PR to allow query params with the trailing history location is merged
2+
* https://github.com/empress/guidemaker/pull/117
3+
*/
4+
5+
/* eslint-disable ember/no-classic-classes, prettier/prettier */
6+
import HistoryLocation from '@ember/routing/history-location';
7+
8+
export default HistoryLocation.extend({
9+
formatURL() {
10+
let url = this._super(...arguments);
11+
return formatURL(url);
12+
},
13+
});
14+
15+
export function formatURL(url) {
16+
let modifiedURL = new URL(url, 'http://example.com');
17+
modifiedURL.pathname += '/';
18+
return `${modifiedURL.pathname}${modifiedURL.search}${modifiedURL.hash}`;
19+
}

app/routes/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class ApplicationRoute extends GuideMakerApp {
1111
model(params, ...rest) {
1212
let { feature_flags } = params;
1313
let overrides = Object.fromEntries(
14-
feature_flags?.split(',').map((flag) => [flag, true]) ?? []
14+
feature_flags?.split(',').map((flag) => [flag, true]) ?? [],
1515
);
1616
this.features.setupFeatures(Object.assign({}, FEATURES, overrides));
1717
return super.model(params, ...rest);

0 commit comments

Comments
 (0)