From b6d05091c5b71a6993ab978c3a05712998538e35 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Tue, 17 Dec 2024 13:51:14 -0500 Subject: [PATCH] Add the trailing-history location locally with support for query params until https://github.com/empress/guidemaker/pull/117 is merged and released --- app/locations/trailing-history.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/locations/trailing-history.js diff --git a/app/locations/trailing-history.js b/app/locations/trailing-history.js new file mode 100644 index 0000000000..3f12264be4 --- /dev/null +++ b/app/locations/trailing-history.js @@ -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}`; +}