Skip to content

Commit 3466884

Browse files
committed
Fix unified flattenToAppURL
1 parent 48baf8c commit 3466884

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

apps/seven/app/loaders/content.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,12 @@ const expand = ['navroot', 'breadcrumbs', 'navigation'];
1212
* This could be a potential use case for the upcoming RR7 middleware
1313
*/
1414
function flattenToAppURL(data: Content, request: Request) {
15-
const currentUrl = new URL(request.url);
16-
const baseUrl = `${currentUrl.protocol}//${currentUrl.host}`;
17-
1815
// Convert data to string to perform replacements
1916
let stringData = JSON.stringify(data);
2017

2118
// Replace all occurrences of backend URLs
22-
stringData = stringData.replace(
23-
new RegExp(config.settings.apiPath, 'g'),
24-
baseUrl,
25-
);
19+
stringData = stringData.replaceAll(`${config.settings.apiPath}/`, '/');
20+
stringData = stringData.replaceAll(config.settings.apiPath, '/');
2621

2722
// Parse back to object
2823
return JSON.parse(stringData);

apps/seven/app/root.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import stylesheet from '../addons.styles.css?url';
2626

2727
function useNavigate() {
2828
const navigate = useRRNavigate();
29-
return (to: string) => navigate(flattenToAppURL(to) || '');
29+
return (to: string) => navigate(to);
3030
}
3131

3232
function useHrefLocal(to: string) {
33-
return useHref(flattenToAppURL(to) || '');
33+
return useHref(to);
3434
}
3535

3636
export const meta: Route.MetaFunction = ({ data }) => [

0 commit comments

Comments
 (0)