From 5bf52cab11a7f1663be9eb9cf9afa7f331f0a13c Mon Sep 17 00:00:00 2001 From: tpluscode Date: Fri, 19 Aug 2022 13:36:39 +0200 Subject: [PATCH] fix(routing): preserve hash --- .changeset/brave-snails-sort.md | 5 +++++ packages/routing/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/brave-snails-sort.md diff --git a/.changeset/brave-snails-sort.md b/.changeset/brave-snails-sort.md new file mode 100644 index 0000000..35bacb3 --- /dev/null +++ b/.changeset/brave-snails-sort.md @@ -0,0 +1,5 @@ +--- +"@hydrofoil/shell-routing": patch +--- + +Preserve hash fragment when routing changes diff --git a/packages/routing/index.ts b/packages/routing/index.ts index 237e9cb..6698498 100644 --- a/packages/routing/index.ts +++ b/packages/routing/index.ts @@ -25,7 +25,7 @@ export const routing = ({ appPath = '/', pathPrefix = '' }: Options = {}) => { const path = resourceUrl.pathname.replace(prefixPattern, '') if (url.hostname === resourceUrl.hostname) { - return `${appPath}${path}${resourceUrl.search}` + return `${appPath}${path}${resourceUrl.search}${resourceUrl.hash}` } return `${appPath}/${href}` }