1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.getStackFormattedLocation = exports.formatProjectFilePath = void 0; 4function formatProjectFilePath(projectRoot, file) { 5 if (file == null) { 6 return '<unknown>'; 7 } 8 return pathRelativeToPath(file.replace(/\\/g, '/'), projectRoot.replace(/\\/g, '/')).replace(/\?.*$/, ''); 9} 10exports.formatProjectFilePath = formatProjectFilePath; 11function pathRelativeToPath(path, relativeTo, sep = '/') { 12 const relativeToParts = relativeTo.split(sep); 13 const pathParts = path.split(sep); 14 let i = 0; 15 while (i < relativeToParts.length && i < pathParts.length) { 16 if (relativeToParts[i] !== pathParts[i]) { 17 break; 18 } 19 i++; 20 } 21 return pathParts.slice(i).join(sep); 22} 23function getStackFormattedLocation(projectRoot, frame) { 24 const column = frame.column != null && parseInt(String(frame.column), 10); 25 const location = formatProjectFilePath(projectRoot, frame.file) + 26 (frame.lineNumber != null 27 ? ':' + frame.lineNumber + (column && !isNaN(column) ? ':' + (column + 1) : '') 28 : ''); 29 return location; 30} 31exports.getStackFormattedLocation = getStackFormattedLocation; 32//# sourceMappingURL=formatProjectFilePath.js.map