Skip to content

Commit

Permalink
. B fix path extractor for linux/mac
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed May 18, 2024
1 parent 4f7346c commit c016be7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/src/core/file_path_extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ class FilePathExtractor {
final match = uriRegExp.firstMatch(stackTraceString);

if (match != null) {
final rawPath = match.group(1)!;
final filePath = isWindows ? Uri.file(rawPath, windows: true).toFilePath(windows: true) : Uri.file(rawPath).toFilePath();
return filePath;
if (isWindows) {
final rawPath = match.group(1)!;
final filePath = Uri.file(rawPath, windows: true).toFilePath(windows: true);
return filePath;
} else {
final filePath = Uri.tryParse('file:///${match.group(1)!}');
return filePath!.toFilePath();
}
} else {
throw FileNotFoundException(
message: 'File not found in stack trace',
Expand All @@ -32,5 +37,5 @@ class FilePathExtractor {
static bool isWindows = Platform.isWindows;

static const String _windowsPattern = r'file:///([a-zA-Z]:/[^:\s]+)';
static const String _linuxMacOSPattern = r'file:///([^:\s]+)';
static const String _linuxMacOSPattern = r'file:\/\/\/([^\s:]+)';
}

0 comments on commit c016be7

Please sign in to comment.