From 9fee649a64a8b70cf2d4e113860a9077638886dc Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Tue, 13 Nov 2018 17:49:29 +0200 Subject: [PATCH] Adjusted how drive letter is trimmed and improved test. --- src/Formatter/Backtrace_Formatter.php | 10 +++++++--- tests/Formatter/BacktraceTest.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Formatter/Backtrace_Formatter.php b/src/Formatter/Backtrace_Formatter.php index fb221bf..c8a4eb0 100644 --- a/src/Formatter/Backtrace_Formatter.php +++ b/src/Formatter/Backtrace_Formatter.php @@ -29,8 +29,8 @@ class Backtrace_Formatter { public function __construct() { $this->truncate_paths = [ - wp_normalize_path( realpath( WP_CONTENT_DIR ) ), - wp_normalize_path( realpath( ABSPATH ) ), + wp_normalize_path( WP_CONTENT_DIR ), + wp_normalize_path( ABSPATH ), 'wp-admin/', 'themes/', 'plugins/', @@ -83,7 +83,11 @@ class Backtrace_Formatter { $path = substr( $item, strpos( $item, '(\'' ) + 2, - 2 ); $path = wp_normalize_path( $path ); - $path = ltrim( str_replace( $this->truncate_paths, '', $path ), '/' ); + $path = str_replace( $this->truncate_paths, '', $path ); + if ( ':' === $path[1] ) { + $path = substr( $path, 2 ); + } + $path = ltrim( $path, '/' ); return $path; } diff --git a/tests/Formatter/BacktraceTest.php b/tests/Formatter/BacktraceTest.php index eba951c..99ecfdd 100644 --- a/tests/Formatter/BacktraceTest.php +++ b/tests/Formatter/BacktraceTest.php @@ -44,7 +44,7 @@ class BacktraceTest extends LapsTestCase { 'template-loader.php', 'WP_Hook->do_action', 'foo', - "include('/wp/path.php')", + "include('C:/wp/path.php')", ]; $backtrace = implode( ', ', $backtrace );