Skip to content

Commit

Permalink
Fix routing breaking when URL parameters are present
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored and DavieReid committed Dec 6, 2023
1 parent 4c5426a commit e3f4b7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/calm-pants-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@jpmorganchase/mosaic-site-middleware': patch
---

Fixed routing breaking when URL parameters are present.
9 changes: 8 additions & 1 deletion packages/site-middleware/src/withMDXContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ import { compileMDX } from './compileMdx.js';
if (typeof window !== 'undefined') {
throw new Error('This file should not be loaded on the client.');
}
function stripParams(resolvedUrl: string) {
const url = new URL(resolvedUrl, 'https://example.com');
return url.pathname;
}

const normalizeUrl = url => (/\/index$/.test(url) ? `${url}.mdx` : url);
function normalizeUrl(url: string) {
const pathname = stripParams(url);
return /\/index$/.test(pathname) ? `${pathname}.mdx` : pathname;
}

async function loadSnapshotFile(url) {
const { snapshotDir } = getSnapshotFileConfig(url);
Expand Down

1 comment on commit e3f4b7c

@vercel
Copy link

@vercel vercel bot commented on e3f4b7c Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mosaic – ./

mosaic-mosaic-dev-team.vercel.app
mosaic-git-main-mosaic-dev-team.vercel.app

Please sign in to comment.