Skip to content

Commit 03fab10

Browse files
committed
Fix an issue with missing basePath being treated as an absolute path
1 parent 7bbc81b commit 03fab10

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313
- Fix an issue where a typo in ModuleInstaller prevented it from working properly.
14+
- Fix an issue with missing basePath being treated as an absolute path.
1415

1516
## [0.0.1] - 2019-06-03
1617

src/ComposerInstaller/BaseInstaller.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ protected function getBasePath($defaultBasePath) {
5454
$type = strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', substr($class, 0, strrpos($class, 'Installer'))));
5555
$basePath = $extra['pw-' . $type . '-path'] ?? $defaultBasePath;
5656

57+
// if base path is set, make sure that it has a trailing slash
58+
$basePath = trim($basePath, '/');
59+
if (strlen($basePath)) {
60+
$basePath .= '/';
61+
}
62+
5763
return $basePath;
5864
}
5965

@@ -89,7 +95,6 @@ protected function getName(PackageInterface $package) {
8995
protected function getFullPath(PackageInterface $package, $defaultBasePath) {
9096
$basePath = $this->getBasePath($defaultBasePath);
9197
$name = $this->getName($package);
92-
$path = trim($basePath, '/') . '/' . $name;
93-
return $path;
98+
return $basePath . $name;
9499
}
95100
}

0 commit comments

Comments
 (0)