Skip to content

Fix Windows path resolution for drive-letter paths#23

Merged
PovilasKorop merged 1 commit into
mainfrom
issue/22
Feb 24, 2026
Merged

Fix Windows path resolution for drive-letter paths#23
PovilasKorop merged 1 commit into
mainfrom
issue/22

Conversation

@krekas
Copy link
Copy Markdown
Collaborator

@krekas krekas commented Feb 24, 2026

Fixes #22 - Windows path resolution bug when running filacheck on a Windows Dev drive (e.g. D:\example).

The absolute path check only looked for Unix-style / prefix, so Windows drive-letter paths like D:\example/app/Filament were treated as relative and prepended with getcwd() again, producing an invalid duplicated path.

Before

// Only detects Unix absolute paths
if (! str_starts_with($path, '/')) {
    $path = getcwd().'/'.$path;
}

// On Windows with D:\example:
// getcwd() returns "D:\example"
// $path = "D:\example/app/Filament" — does NOT start with "/"
// Result: "D:\example/D:\example/app/Filament" — BROKEN

After

function isAbsolutePath(string $path): bool
{
    return str_starts_with($path, '/') || preg_match('/^[A-Za-z]:[\\\\\/]/', $path) === 1;
}

if (! isAbsolutePath($path)) {
    $path = getcwd().DIRECTORY_SEPARATOR.$path;
}

// On Windows with D:\example:
// getcwd() returns "D:\example"
// $path = "D:\example\app\Filament" — isAbsolutePath() returns true
// Result: "D:\example\app\Filament" — CORRECT

Changes

  • Added isAbsolutePath() helper that detects both Unix (/...) and Windows (C:\..., C:/...) absolute paths
  • Replaced str_starts_with($path, '/') check with isAbsolutePath($path)
  • Replaced hardcoded / separators with DIRECTORY_SEPARATOR when joining paths with getcwd()

@krekas krekas added the bug Something isn't working label Feb 24, 2026
@krekas krekas marked this pull request as draft February 24, 2026 12:57
@krekas krekas marked this pull request as ready for review February 24, 2026 15:29
@PovilasKorop PovilasKorop merged commit 748ae93 into main Feb 24, 2026
@PovilasKorop PovilasKorop deleted the issue/22 branch February 24, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vendor/bin/filacheck unable to find directory on Windows/Powershell

2 participants