From 32c6c76a2129e42a786f17883b2e9f806f45dfb9 Mon Sep 17 00:00:00 2001 From: Kylie C Date: Thu, 19 Dec 2024 00:51:56 -0500 Subject: [PATCH 1/2] fix: process detection if its a single path `i = 1` rightly skips the first index as it is commonly empty (on linux) or a drive letter (windows) but this wrongly captures single path processes on linux. This explicitly filters out those undesired first indexes instead of skipping ALL of them. --- src/process/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/process/index.js b/src/process/index.js index f445024..389b084 100644 --- a/src/process/index.js +++ b/src/process/index.js @@ -34,11 +34,14 @@ export default class ProcessServer { // log(`got processed in ${(performance.now() - startTime).toFixed(2)}ms`); - for (const [ pid, _path, args ] of processes) { - const path = _path.toLowerCase().replaceAll('\\', '/'); + for (const [ pid, path, args ] of processes) { + const splitPath = path.toLowerCase().replaceAll('\\', '/').split('/'); + if ((/^[a-z]:$/.test(splitPath[0]) || splitPath[0] == "")) { + splitPath.shift(); // drop the first index if its a drive letter or empty + } + const toCompare = []; - const splitPath = path.split('/'); - for (let i = 1; i < splitPath.length; i++) { + for (let i = 0; i < splitPath.length; i++) { toCompare.push(splitPath.slice(-i).join('/')); } From 0be356f56064424faa31009616a4ea1eb46c5492 Mon Sep 17 00:00:00 2001 From: Cookie <52550063+Covkie@users.noreply.github.com> Date: Thu, 6 Feb 2025 19:30:38 -0500 Subject: [PATCH 2/2] non regex path parse --- src/process/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/process/index.js b/src/process/index.js index 389b084..ee43ac4 100644 --- a/src/process/index.js +++ b/src/process/index.js @@ -36,7 +36,7 @@ export default class ProcessServer { for (const [ pid, path, args ] of processes) { const splitPath = path.toLowerCase().replaceAll('\\', '/').split('/'); - if ((/^[a-z]:$/.test(splitPath[0]) || splitPath[0] == "")) { + if ((splitPath[0] == 2 && splitPath[0].endsWith(':') || splitPath[0] == "")) { splitPath.shift(); // drop the first index if its a drive letter or empty }