From d4191c4a269fe29b6b5c50de9e9be09a51cd0f8d Mon Sep 17 00:00:00 2001 From: Fabio Spampinato Date: Mon, 26 Oct 2020 03:19:35 +0000 Subject: [PATCH] fix: optimized asar paths checks (#26024) * fix: optimized asar paths checks * fix: ensuring the linter is happy --- lib/asar/fs-wrapper.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/asar/fs-wrapper.ts b/lib/asar/fs-wrapper.ts index 34f5a4ecc6..be0cc8aa62 100644 --- a/lib/asar/fs-wrapper.ts +++ b/lib/asar/fs-wrapper.ts @@ -37,6 +37,8 @@ const getOrCreateArchive = (archivePath: string) => { return newArchive; }; +const asarRe = /\.asar/i; + // Separate asar package's path from full path. const splitPath = (archivePathOrBuffer: string | Buffer) => { // Shortcut for disabled asar. @@ -48,6 +50,7 @@ const splitPath = (archivePathOrBuffer: string | Buffer) => { archivePath = archivePathOrBuffer.toString(); } if (typeof archivePath !== 'string') return { isAsar: false }; + if (!asarRe.test(archivePath)) return { isAsar: false }; return asar.splitPath(path.normalize(archivePath)); };