Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 4f1457e

Browse files
authored
Prevent messing up file extension
Make sure that appdir and slashes are only removed from the beginning of the string
1 parent 3937e64 commit 4f1457e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/formatter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,10 @@ let _getFileDetails = function (logEvent) {
475475
if (typeof define !== 'undefined') {
476476
let path = require('path');
477477
let appDir = path.dirname(require.main.filename);
478-
if (appDir == '.') {
479-
appDir = '';
480-
}
481-
logEvent.filename = fileParts.join(':').replace(appDir, '').replace(/(\\|\/)/, '');
478+
if (!fileParts[0].startsWith(appDir)) {
479+
appDir = '';
480+
}
481+
logEvent.filename = fileParts.join(':').replace(appDir, '').replace(/^(\\|\/)/, '');
482482
} else {
483483
logEvent.filename = fileParts.join(':');
484484
}

0 commit comments

Comments
 (0)