Skip to content

Commit

Permalink
Revert .ico support
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Apr 11, 2022
1 parent c2703b3 commit 45a8acc
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions src/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function css()
$output = '';

foreach ($cssCollection as $key => $value) {
$output .= '<link '.$this->formatAttributes($value['attributes']+['rel'=>'stylesheet']).'href="'.$value['asset'].'">'."\n";
$output .= '<link rel="stylesheet" '.$this->formatAttributes($value['attributes']).'href="'.$value['asset'].'">'."\n";
}

return $output;
Expand All @@ -133,7 +133,7 @@ public function js()
$output = '';

foreach ($jsCollection as $key => $value) {
$output .= '<script '.$this->formatAttributes($value['attributes']+['type'=>'text/javascript']).'src="'.$value['asset'].'"></script>'."\n";
$output .= '<script type="text/javascript" '.$this->formatAttributes($value['attributes']).'src="'.$value['asset'].'"></script>'."\n";
}

return $output;
Expand All @@ -147,7 +147,7 @@ public function js()
*/
protected function isAsset($asset)
{
return is_string($asset) && preg_match('/.\.(css|js|ico)$/i', $asset);
return preg_match('/.\.(css|js)$/i', (string)$asset);
}

/**
Expand All @@ -158,7 +158,7 @@ protected function isAsset($asset)
*/
protected function isJs($asset)
{
return is_string($asset) && preg_match('/.\.js$/i', $asset);
return preg_match('/.\.js$/i', (string)$asset);
}

/**
Expand All @@ -169,7 +169,7 @@ protected function isJs($asset)
*/
protected function isCss($asset)
{
return is_string($asset) && preg_match('/.\.(css|ico)$/i', $asset);
return preg_match('/.\.css$/i', (string)$asset);
}

/**
Expand All @@ -180,7 +180,7 @@ protected function isCss($asset)
*/
protected function isBonsai($asset)
{
return is_array($asset) || (is_string($asset) && preg_match('/bonsai\.json$/i', $asset));
return is_array($asset) || preg_match('/bonsai\.json$/i', (string)$asset);
}

/**
Expand All @@ -196,7 +196,6 @@ public function add($assets, $namespace = null)
}

$cleanAsset = self::cleanAsset($assets);

if (! $this->isAsset($cleanAsset)) {
$this->lastAddedAsset = '';

Expand All @@ -212,13 +211,6 @@ public function add($assets, $namespace = null)
if (! in_array($cleanAsset, $collection)) {
$collection[$assets] = is_array($namespace) ? $namespace : ['namespace' => $namespace];

if ($type === 'css' && preg_match('/.\.ico$/i', $cleanAsset)) {
$collection[$assets]['attributes'] = ($collection[$assets]['attributes'] ?? []) + [
'rel'=>'icon',
'type'=>'image/x-icon'
];
}

$this->collection->put($type, $collection);
}

Expand Down Expand Up @@ -247,28 +239,6 @@ private static function cleanAsset($asset)
return $asset;
}

/**
* Return the remainder of a string after the last occurrence of a given value.
*
* @param string $subject
* @param string $search
* @return string
*/
public static function afterLast($subject, $search)
{
if ($search === '') {
return $subject;
}

$position = strrpos($subject, (string) $search);

if ($position === false) {
return $subject;
}

return substr($subject, $position + strlen($search));
}

/**
* Parse a bonsai.json file and add the assets to the collection.
*
Expand Down

0 comments on commit 45a8acc

Please sign in to comment.