Skip to content

Commit 8b874e5

Browse files
committed
Fix connected links
1 parent 5a0e083 commit 8b874e5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const query = /\?.*/;
22

3-
const findConnectedLinks = (pathname, navSchema) => navSchema.find(({ link }) => pathname.replace(/^\//, '').replace(query, '') === link);
3+
const findConnectedLinks = (pathname, navSchema) =>
4+
navSchema.find(({ link }) => pathname.replace(/^\//, '').replace(query, '') === link.replace(query, ''));
45

56
export default findConnectedLinks;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import useQueryParam from './use-query-param';
2+
import { query } from '../components/navigation/find-connected-links';
23

34
/**
45
* Appends current query mapper value to URL
56
* @param {string} link url string to be appended with current mapper query param
67
*/
78
const useMapperLink = (link = '') => {
89
const mapperQuery = useQueryParam('mapper');
9-
return link.includes('component-example/') ? `${link}${mapperQuery}` : link;
10+
return link.match(query) && mapperQuery ? `${link.replace(query, '')}${mapperQuery}` : link;
1011
};
1112

1213
export default useMapperLink;

0 commit comments

Comments
 (0)