Created
March 18, 2026 06:40
-
-
Save JoshSalway/61208845ee8512451f41431568231123 to your computer and use it in GitHub Desktop.
Fix for laravel/vs-code-extension #575 - Check if component path is absolute before prepending base_path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 558ebdafd4fa00bdcaa76d54e2c05dbf337f07c4 Mon Sep 17 00:00:00 2001 | |
| From: Josh Salway <josh.salway@gmail.com> | |
| Date: Wed, 18 Mar 2026 16:40:01 +1000 | |
| Subject: [PATCH] Check if component path is absolute before prepending | |
| base_path | |
| When using Composer path repositories with symlinks pointing outside | |
| the project directory, component paths are resolved to absolute paths. | |
| The parseProps method then prepends base_path(), producing invalid | |
| double paths like C:\project\C:\packages\... | |
| Check if the path starts with a drive letter or forward slash before | |
| calling base_path(). | |
| Fixes #575 | |
| Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> | |
| --- | |
| php-templates/blade-components.php | 6 +++++- | |
| src/templates/blade-components.ts | 6 +++++- | |
| 2 files changed, 10 insertions(+), 2 deletions(-) | |
| diff --git a/php-templates/blade-components.php b/php-templates/blade-components.php | |
| index bbd8501..001c385 100644 | |
| --- a/php-templates/blade-components.php | |
| +++ b/php-templates/blade-components.php | |
| @@ -350,7 +350,11 @@ $components = new class { | |
| protected function parseProps($compiler, array $component): ?string | |
| { | |
| - $content = file_get_contents(base_path($component['path'])); | |
| + $path = $component['path']; | |
| + $isAbsolute = str_starts_with($path, '/') || preg_match('/^[a-zA-Z]:/', $path); | |
| + $fullPath = $isAbsolute ? $path : base_path($path); | |
| + | |
| + $content = file_get_contents($fullPath); | |
| $result = ''; | |
| diff --git a/src/templates/blade-components.ts b/src/templates/blade-components.ts | |
| index a88ada2..7182f76 100644 | |
| --- a/src/templates/blade-components.ts | |
| +++ b/src/templates/blade-components.ts | |
| @@ -350,7 +350,11 @@ $components = new class { | |
| protected function parseProps($compiler, array $component): ?string | |
| { | |
| - $content = file_get_contents(base_path($component['path'])); | |
| + $path = $component['path']; | |
| + $isAbsolute = str_starts_with($path, '/') || preg_match('/^[a-zA-Z]:/', $path); | |
| + $fullPath = $isAbsolute ? $path : base_path($path); | |
| + | |
| + $content = file_get_contents($fullPath); | |
| $result = ''; | |
| -- | |
| 2.53.0.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment