Skip to content

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

fix: reimplementing getURLParam function

Ilian Sapundshiev7c61248d1666
diff --git a/app/services/webdav-io.ts b/app/services/webdav-io.ts
index d80dbf9f3..a2b7ff1f5 100644
--- a/app/services/webdav-io.ts
+++ b/app/services/webdav-io.ts
@@ -131,16 +131,6 @@ export default class WebDAVIO {
return false;
};
- // TODO
- handleStartParameters = (): void => {
- /* let filePath = getURLParameter('open');
- if (filePath && filePath.length > 0) {
- filePath = decodeURIComponent(filePath);
- console.log('Opening file in browser: ' + filePath);
- FileOpener.openFileOnStartup(filePath);
- } */
- };
-
/**
* Creates recursively a tree structure for a given directory path
* @param {string} dirPath - the full path of the directory for which the tree will be generated
diff --git a/app/utils/misc.ts b/app/utils/misc.ts
index 4c84287fa..3fc90d611 100644
--- a/app/utils/misc.ts
+++ b/app/utils/misc.ts
@@ -135,16 +135,10 @@ export function isVisibleOnScreen(element: any) {
return isVisible;
}
-export function getURLParameter(variable: string) {
- const query = window.location.search.substring(1);
- const vars = query.split('&');
- for (let i = 0; i < vars.length; i += 1) {
- const pair = vars[i].split('=');
- if (pair[0] === variable) {
- return pair[1];
- }
- }
- return false;
+export function getURLParameter(paramName: string, url?: string): string {
+ const intUrl = url || window.location.href;
+ const params = new URL(intUrl).searchParams;
+ return params.get(paramName);
}
export function dataURLtoBlob(dataURI) {