Remove static/public method
parent
489a8f3d5a
commit
c0e28a9043
|
@ -175,27 +175,6 @@ class RemoteFilesystem
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @link https://github.com/composer/composer/issues/5584
|
|
||||||
*
|
|
||||||
* @param string $urlToBitBucketFile URL to a file at bitbucket.org.
|
|
||||||
*
|
|
||||||
* @return bool Whether the given URL is a public BitBucket download which requires no authentication.
|
|
||||||
*/
|
|
||||||
public static function urlIsPublicBitBucketDownload($urlToBitBucketFile)
|
|
||||||
{
|
|
||||||
$path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
|
|
||||||
|
|
||||||
// Path for a public download follows this pattern /{user}/{repo}/downloads/{whatever}
|
|
||||||
// {@link https://blog.bitbucket.org/2009/04/12/new-feature-downloads/}
|
|
||||||
$pathParts = explode('/', $path);
|
|
||||||
if (count($pathParts) >= 4 && $pathParts[2] != 'downloads') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get file content or copy action.
|
* Get file content or copy action.
|
||||||
*
|
*
|
||||||
|
@ -267,8 +246,8 @@ class RemoteFilesystem
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['bitbucket-token'])) {
|
if (isset($options['bitbucket-token'])) {
|
||||||
// First time be optimistic and do not use the token for a BitBucket download.
|
// skip using the token for BitBucket downloads as these are not working with auth
|
||||||
if (!static::urlIsPublicBitBucketDownload($origFileUrl)) {
|
if (!$this->isPublicBitBucketDownload($origFileUrl)) {
|
||||||
$fileUrl .= (false === strpos($fileUrl,'?') ? '?' : '&') . 'access_token=' . $options['bitbucket-token'];
|
$fileUrl .= (false === strpos($fileUrl,'?') ? '?' : '&') . 'access_token=' . $options['bitbucket-token'];
|
||||||
}
|
}
|
||||||
unset($options['bitbucket-token']);
|
unset($options['bitbucket-token']);
|
||||||
|
@ -366,7 +345,7 @@ class RemoteFilesystem
|
||||||
|
|
||||||
// check for bitbucket login page asking to authenticate
|
// check for bitbucket login page asking to authenticate
|
||||||
if ($originUrl === 'bitbucket.org'
|
if ($originUrl === 'bitbucket.org'
|
||||||
&& !static::urlIsPublicBitBucketDownload($fileUrl)
|
&& !$this->isPublicBitBucketDownload($fileUrl)
|
||||||
&& substr($fileUrl, -4) === '.zip'
|
&& substr($fileUrl, -4) === '.zip'
|
||||||
&& preg_match('{^text/html\b}i', $contentType)
|
&& preg_match('{^text/html\b}i', $contentType)
|
||||||
) {
|
) {
|
||||||
|
@ -1007,4 +986,25 @@ class RemoteFilesystem
|
||||||
|
|
||||||
return parse_url($url, PHP_URL_HOST).':'.$port;
|
return parse_url($url, PHP_URL_HOST).':'.$port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://github.com/composer/composer/issues/5584
|
||||||
|
*
|
||||||
|
* @param string $urlToBitBucketFile URL to a file at bitbucket.org.
|
||||||
|
*
|
||||||
|
* @return bool Whether the given URL is a public BitBucket download which requires no authentication.
|
||||||
|
*/
|
||||||
|
private function isPublicBitBucketDownload($urlToBitBucketFile)
|
||||||
|
{
|
||||||
|
$path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
|
||||||
|
|
||||||
|
// Path for a public download follows this pattern /{user}/{repo}/downloads/{whatever}
|
||||||
|
// {@link https://blog.bitbucket.org/2009/04/12/new-feature-downloads/}
|
||||||
|
$pathParts = explode('/', $path);
|
||||||
|
if (count($pathParts) >= 4 && $pathParts[2] != 'downloads') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue