File tree Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,17 @@ public function actionContact()
4646
4747 public function actionSearch ($ query )
4848 {
49- $ package = $ this ->getAssetPackage ($ query );
50- $ params = ['package ' => $ package , 'query ' => $ query , 'forceUpdate ' => false ];
49+ try {
50+ $ package = $ this ->getAssetPackage ($ query );
51+ $ params = ['package ' => $ package , 'query ' => $ query , 'forceUpdate ' => false ];
52+
53+ if ($ package ->canAutoUpdate ()) {
54+ $ params ['forceUpdate ' ] = true ;
55+ }
56+ } catch (\Exception $ e ) {
57+ $ query = strtolower (preg_replace ('/[^a-z0-9-]/i ' , '' , $ query ));
5158
52- if ($ package ->canAutoUpdate ()) {
53- $ params ['forceUpdate ' ] = true ;
59+ return $ this ->render ('notFound ' , compact ('query ' ));
5460 }
5561
5662 return $ this ->render ('search ' , $ params );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @var $this yii\web\View
5+ * @var string $query the search query that was submitted
6+ * @var \hiqdev\assetpackagist\models\AssetPackage $package
7+ * @var bool $forceUpdate Whether the application must force package update
8+ */
9+
10+ use yii \helpers \Html ;
11+ use yii \helpers \Inflector ;
12+ use yii \helpers \Json ;
13+ use yii \helpers \Url ;
14+
15+ $ this ->title = 'Not found ' ;
16+ $ this ->params ['searchQuery ' ] = $ query ;
17+
18+ ?>
19+
20+ <div class="package-details">
21+ <h1>
22+ <?= $ this ->title ?>
23+ </h1>
24+ <h1>
25+ <small class="repository-link">
26+ Please use: <a href="/site/search?query=bower-asset/<?= $ query ?> ">bower-asset/<?= $ query ?> </a> or
27+ <a href="/site/search?query=npm-asset/<?= $ query ?> ">npm-asset/<?= $ query ?> </a>
28+ </small>
29+ </h1>
30+ </div>
You can’t perform that action at this time.
0 commit comments