Skip to content

Commit 563d376

Browse files
author
Jicheng Lu
committed
compare clean path
1 parent 39a8a84 commit 563d376

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/lib/common/embedding/EmbeddingPage.svelte

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { onMount } from 'svelte';
33
import { page } from '$app/stores';
44
import { getUserStore, globalMenuStore } from '$lib/helpers/store';
5+
import { getCleanUrl } from '$lib/helpers/utils/common';
56
67
let {
78
htmlTagId = 'embedding-page',
@@ -25,12 +26,12 @@
2526
2627
onMount(() => {
2728
const menuUnsubscribe = globalMenuStore.subscribe((/** @type {import('$pluginTypes').PluginMenuDefModel[]} */ menu) => {
28-
const url = getPathUrl();
29-
let found = menu.find(x => x.link === url);
29+
const url = getCleanPath(getPathUrl());
30+
let found = menu.find(x => getCleanPath(x.link) === url);
3031
label = found?.label || '';
3132
if (!found?.embeddingInfo) {
32-
const subFound = menu.find(x => !!x.subMenu?.find(y => y.link === url));
33-
found = subFound?.subMenu?.find(x => x.link === url);
33+
const subFound = menu.find(x => !!x.subMenu?.find(y => getCleanPath(y.link) === url));
34+
found = subFound?.subMenu?.find(x => getCleanPath(x.link) === url);
3435
label = found?.label || '';
3536
}
3637
embed(found?.embeddingInfo || null);
@@ -77,9 +78,13 @@
7778
}
7879
}
7980
81+
/** @param {string} url */
82+
const getCleanPath = (url) => {
83+
return getCleanUrl((url || '').split('?')[0]);
84+
};
85+
8086
const getPathUrl = () => {
81-
const path = $page.url.pathname;
82-
return path?.startsWith('/') ? path.substring(1) : path;
87+
return $page.url.pathname || '';
8388
};
8489
</script>
8590

0 commit comments

Comments
 (0)