code: private function isPublicBitBucketDownload($urlToBitBucketFile)
      {
          $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
          if (strpos($domain, 'bitbucket.org') === false) {
              // Bitbucket downloads are hosted on amazonaws.
              // We do not need to authenticate there at all
              return true;
          }
  
          $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);
  
          return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
      }
docs: @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.