Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- Some relative paths were parsed as absolute ones
- Resolving a relative path from a root path returned an invalid path (as it started with 2 `/`)

## 5.2.0 - 2026-03-17

Expand Down
4 changes: 4 additions & 0 deletions src/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ final public function resolve(self $path): self

$parent = \dirname($this->toString());

if ($parent === '/') {
return self::of('/'.$path->toString());
}

return self::of($parent.'/'.$path->toString());
}

Expand Down
17 changes: 17 additions & 0 deletions tests/PathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ public function testAbsolutePathsAlwaysStartWithASlash(): BlackBox\Proof
});
}

public function testResolveAbsolutility(): BlackBox\Proof
{
return $this
->forAll(FPath::any(), FPath::any())
->prove(function($a, $b) {
$this->assertSame(
$a->absolute() || $b->absolute(),
$a->resolve($b)->absolute(),
);
});
}

public static function resolutions(): array
{
return [
Expand Down Expand Up @@ -126,6 +138,11 @@ public static function resolutions(): array
'some/source',
'some/target',
],
'relative to the root' => [
'/target',
'/source',
'target',
],
];
}
}
Loading