public function expandReferences(array $references, PackageVersionEntity $packageVersion)
    {
        if (empty($references)) {
            return $references;
        }
        $gitRepositories = $this->app->make(GitRepositoryRepository::class)->findBy(['packageHandle' => $packageVersion->getPackage()->getHandle()]);
        $applicableRepository = null;
        $foundVersionData = null;
        foreach ($gitRepositories as $gitRepository) {
            $d = $gitRepository->getDetectedVersion($packageVersion->getVersion());
            if ($d !== null) {
                $applicableRepository = $gitRepository;
                $foundVersionData = $d;
                break;
            }
        }

        $pattern = null;
        $lineFormat = null;
        if ($applicableRepository !== null) {
            $matches = null;
            switch (true) {
                case 1 == preg_match('/^(?:\w+:\/\/|\w+@)github.com[:\/]([a-z0-9_.\-]+\/[a-z0-9_.\-]+)\.git$/i', $applicableRepository->getURL(), $matches):
                    switch ($foundVersionData['kind']) {
                        case 'tag':
                            $pattern = 'https://github.com/' . $matches[1] . '/blob/' . $foundVersionData['repoName'] . '/<<FILE>><<LINE>>';
                            $lineFormat = '#L%s';
                            break;
                        case 'branch':
                            $pattern = 'https://github.com/' . $matches[1] . '/blob/' . $foundVersionData['repoName'] . '/<<FILE>><<LINE>>';
                            $lineFormat = '#L%s';
                            break;
                    }
                    break;
            }
        }
        $result = $references;
        if ($pattern !== null) {
            $prefix = $applicableRepository->getDirectoryToParse();
            if ($prefix !== '') {
                $prefix .= '/';
            }
            $stripSuffix = $applicableRepository->getDirectoryForPlaces();
            if ($stripSuffix !== '') {
                $stripSuffix .= '/';
            }
            $m = null;
            foreach ($result as $index => $reference) {
                if (!preg_match('/^\w*:\/\//', $reference)) {
                    if (preg_match('/^(.+):(\d+)$/', $reference, $m)) {
                        $file = $m[1];
                        $line = $m[2];
                    } else {
                        $file = $reference;
                        $line = null;
                    }
                    $file = ltrim($file, '/');
                    $line = ($line === null || $lineFormat === null) ? '' : sprintf($lineFormat, $line);
                    if ($stripSuffix !== '' && strpos($file, $stripSuffix) === 0) {
                        $file = $prefix . substr($file, strlen($stripSuffix));
                    }
                    $result[$index] = [
                        str_replace(['<<FILE>>', '<<LINE>>'], [$file, $line], $pattern),
                        $reference,
                    ];
                }
            }
        }

        return $result;
    }