diff --git a/laravel.php b/laravel.php index e2b71b7..33661bb 100644 --- a/laravel.php +++ b/laravel.php @@ -15,7 +15,11 @@ $branch = $matches[1]; $query = $matches[2]; } else { - $branch = empty($_ENV['branch']) ? 'master' : $_ENV['branch']; + $branch = $_ENV['branch']; +} + +if ($branch === 'latest') { + $branch = null; } $subtext = empty($_ENV['alfred_theme_subtext']) ? '0' : $_ENV['alfred_theme_subtext']; @@ -27,7 +31,7 @@ AlgoliaUserAgent::addSuffixUserAgentSegment('Alfred Workflow', '0.2.2'); $index = $algolia->initIndex('docs'); -$search = $index->search($query, ['tagFilters' => $branch]); +$search = $index->search($query, ['tagFilters' => $branch ?: 'master']); $results = $search['hits']; $subtextSupported = $subtext === '0' || $subtext === '2'; @@ -55,10 +59,11 @@ exit; } +$docs = sprintf('https://laravel.com/docs/%s', $branch ? $branch . '/' : ''); $urls = []; foreach ($results as $hit) { - $url = sprintf("https://laravel.com/docs/%s/%s", $branch, $hit['link']); + $url = $docs . $hit['link']; if (in_array($url, $urls)) { continue;