diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 497df1e2a..2a66a4bf6 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -526,12 +526,19 @@ EOF; protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix) { + $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode)-1]; + if ("'" === $lastChar || '"' === $lastChar) { + $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar; + } else { + $vendorPathToTargetDirCode .= " . '/autoload_real.php'"; + } + return <<config = $config; $this->options = $repoConfig['options']; $this->url = $repoConfig['url']; - $this->baseUrl = rtrim(preg_replace('{^(.*)(?:/[^/\\]+.json)?(?:[?#].*)?$}', '$1', $this->url), '/'); + $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/'); $this->io = $io; $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$'); $this->loader = new ArrayLoader(); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_functions.php index 01f2142ff..60f233da1 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_functions.php @@ -2,6 +2,6 @@ // autoload.php @generated by Composer -require_once __DIR__ . '/composer' . '/autoload_real.php'; +require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInitFilesAutoload::getLoader(); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_functions_by_dependency.php b/tests/Composer/Test/Autoload/Fixtures/autoload_functions_by_dependency.php index 2f68d7b05..f032a65c6 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_functions_by_dependency.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_functions_by_dependency.php @@ -2,6 +2,6 @@ // autoload.php @generated by Composer -require_once __DIR__ . '/composer' . '/autoload_real.php'; +require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInitFilesAutoloadOrder::getLoader(); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php index 63ef49f61..d117d6d48 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php @@ -2,6 +2,6 @@ // autoload.php @generated by Composer -require_once __DIR__ . '/composer' . '/autoload_real.php'; +require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInitTargetDir::getLoader();