Commit 300654e786
Unsigned
Layout: unified · split
docs/.vitepress/theme/Layout.vue +18 −4
| @@ -711,10 +711,24 @@ onMounted(() => { | ||
| 711 | 711 | const tabFromHash = raw.startsWith('#' + TAB_LINK_MARKER) |
| 712 | 712 | ? raw.slice(1 + TAB_LINK_MARKER.length) |
| 713 | 713 | : null |
| 714 | const tabFromQuery = | |
| 715 | !tabFromHash && raw.includes(`?${TAB_QUERY_PARAM}=`) && !raw.includes('#') | |
| 716 | ? new URLSearchParams(raw.split('?')[1]).get(TAB_QUERY_PARAM) | |
| 717 | : null | |
| 714 | let tabFromQuery: string | null = null | |
| 715 | if ( | |
| 716 | !e.defaultPrevented && | |
| 717 | !tabFromHash && | |
| 718 | raw.includes(`?${TAB_QUERY_PARAM}=`) && | |
| 719 | !raw.includes('#') | |
| 720 | ) { | |
| 721 | try { | |
| 722 | const url = new URL(raw, window.location.href) | |
| 723 | const samePage = url.origin === window.location.origin && | |
| 724 | url.pathname === window.location.pathname | |
| 725 | tabFromQuery = samePage | |
| 726 | ? url.searchParams.get(TAB_QUERY_PARAM) | |
| 727 | : null | |
| 728 | } catch { | |
| 729 | tabFromQuery = null | |
| 730 | } | |
| 731 | } | |
| 718 | 732 | const tabName = tabFromHash ?? tabFromQuery |
| 719 | 733 | |
| 720 | 734 | if (tabName) { |