From 0f2d07e7dd137c1808dfdc4fc80b7766304cbee4 Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Wed, 28 Jun 2023 15:46:48 +0200 Subject: [PATCH 1/3] Using `path.posix` instead of string manipulation --- preload.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/preload.js b/preload.js index ad01aa5..5c64017 100644 --- a/preload.js +++ b/preload.js @@ -74,13 +74,13 @@ const Serial = { return board.exit_raw_repl() }, getNavigationPath: (navigation, target) => { - return [navigation, target].filter(p => p).join('/') + return path.posix.join(navigation, target) }, getFullPath: (root, navigation, file) => { - return root + [navigation, file].filter(p => p).join('/') + return path.posix.join('/', navigation, file) }, getParentPath: (filePath) => { - return filePath.split('/').slice(0, -1).join('/') + return path.posix.dirname(navigation) } } From 3b85961d845eb0cc741374e411d9637868580367 Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Wed, 28 Jun 2023 15:53:17 +0200 Subject: [PATCH 2/3] Fix variable name --- preload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preload.js b/preload.js index 5c64017..65942bc 100644 --- a/preload.js +++ b/preload.js @@ -79,7 +79,7 @@ const Serial = { getFullPath: (root, navigation, file) => { return path.posix.join('/', navigation, file) }, - getParentPath: (filePath) => { + getParentPath: (navigation) => { return path.posix.dirname(navigation) } } From 9a409411a25051147d026d9fa99df802595175b8 Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Wed, 28 Jun 2023 16:30:14 +0200 Subject: [PATCH 3/3] Use argument instead of constant --- preload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preload.js b/preload.js index 65942bc..f333f98 100644 --- a/preload.js +++ b/preload.js @@ -77,7 +77,7 @@ const Serial = { return path.posix.join(navigation, target) }, getFullPath: (root, navigation, file) => { - return path.posix.join('/', navigation, file) + return path.posix.join(root, navigation, file) }, getParentPath: (navigation) => { return path.posix.dirname(navigation)