Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: refactoring getting url params from tslinks

Ilian Sapundshievffb1d2219fa7
diff --git a/src/renderer/components/LinksTab.tsx b/src/renderer/components/LinksTab.tsx
index 877211cba..c6b1cfde5 100644
--- a/src/renderer/components/LinksTab.tsx
+++ b/src/renderer/components/LinksTab.tsx
@@ -25,7 +25,6 @@ import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { getEntryContainerTab } from '-/reducers/settings';
import { TS } from '-/tagspaces.namespace';
-import { getURLParameter } from '-/utils/dom';
import { Box, Typography } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { extractLinks } from '@tagspaces/tagspaces-common/misc';
@@ -107,7 +106,7 @@ function LinksTab(props: Props) {
const outgoingLinkButton = (link: TS.Link) => {
let url = link.value ? link.value : link.href;
url = url.split('\\').join(''); // tmp fix for milkdown issue
- let buttonTitle = url;
+ let buttonTitle = '';
if (link.type === 'url') {
try {
buttonTitle = new URL(url).hostname;
@@ -117,11 +116,11 @@ function LinksTab(props: Props) {
} else if (link.type === 'tslink') {
// file ts://?tslid=dd484720e24d429083d81a5379909798&tsepath=contacts%2Fcontacts-gmail.vcf&tseid=acfa652ede334c9490e6d2672ffdc742
// folder ts://?tslid=dd484720e24d429083d81a5379909798&tsdpath=DeutscheTelecom&tseid=0bae06de993c4fd0a034fb4ab9484992
- const locationId = getURLParameter('tslid', url);
- const folderPath = getURLParameter('tsdpath', url);
- const entryPath = getURLParameter('tsepath', url);
+ const tsUrl = new URL(url);
+ const locationId = tsUrl.searchParams.get('tslid');
+ const folderPath = tsUrl.searchParams.get('tsdpath');
+ const entryPath = tsUrl.searchParams.get('tsepath');
const locationName = findLocation(locationId)?.name;
- buttonTitle = '';
if (locationName) {
buttonTitle = locationName + ' ⇒ ';
}