Browse Source

fix: optimized asar paths checks (#26024)

* fix: optimized asar paths checks

* fix: ensuring the linter is happy
Fabio Spampinato 4 years ago
parent
commit
d4191c4a26
1 changed files with 3 additions and 0 deletions
  1. 3 0
      lib/asar/fs-wrapper.ts

+ 3 - 0
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: <const>false };
+  if (!asarRe.test(archivePath)) return { isAsar: <const>false };
 
   return asar.splitPath(path.normalize(archivePath));
 };