Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix require is not defined

Abdullah Atta5041e47902bc
diff --git a/packages/core/utils/filename.js b/packages/core/utils/filename.js
index 32db39caf..a16a7cf82 100644
--- a/packages/core/utils/filename.js
+++ b/packages/core/utils/filename.js
@@ -16,6 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import db from "mime-db";
// type MimeTypeInfo = {
// source: string;
@@ -24,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// compressible?: boolean;
// };
-let db; // : Record<string, MimeTypeInfo>;
-
/**
*
* @param {string} filename
@@ -34,7 +33,6 @@ let db; // : Record<string, MimeTypeInfo>;
*/
export function getFileNameWithExtension(filename, mime) {
if (!mime || mime === "application/octet-stream") return filename;
- if (!db) db = require("mime-db");
const mimeData = db[mime];
if (!mimeData || !mimeData.extensions || mimeData.extensions.length === 0)
return filename;