* Fix domain name detection #647 * Ignore page links check if no DB configured #641
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Composers;
|
||||
|
||||
use App\Contracts\Composer;
|
||||
use App\Repositories\PageRepository;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
@@ -26,13 +27,18 @@ class PageLinksComposer extends Composer
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
// If not logged in, then only get the public pages
|
||||
$w = ['enabled' => true];
|
||||
if (!Auth::check()) {
|
||||
$w = ['public' => true];
|
||||
try {
|
||||
// If not logged in, then only get the public pages
|
||||
$w = ['enabled' => true];
|
||||
if (!Auth::check()) {
|
||||
$w = ['public' => true];
|
||||
}
|
||||
|
||||
$pages = $this->pageRepo->findWhere($w, ['id', 'name', 'slug', 'icon']);
|
||||
} catch (Exception $e) {
|
||||
$pages = [];
|
||||
}
|
||||
|
||||
$pages = $this->pageRepo->findWhere($w, ['id', 'name', 'slug', 'icon']);
|
||||
$view->with('page_links', $pages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Contracts\Model;
|
||||
use Hashids\Hashids;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Support\Str;
|
||||
use LayerShifter\TLDExtract\Extract;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
|
||||
/**
|
||||
@@ -109,19 +110,14 @@ class Utils
|
||||
*/
|
||||
public static function getRootDomain(string $url): string
|
||||
{
|
||||
if (!Str::contains($url, ['https://', 'http://'])) {
|
||||
$url = 'http://'.$url;
|
||||
if (Str::contains($url, ['https://', 'http://'])) {
|
||||
$url = str_replace('https://', '', $url);
|
||||
$url = str_replace('http://', '', $url);
|
||||
}
|
||||
|
||||
$domain = parse_url($url, PHP_URL_HOST);
|
||||
$domain = explode('.', $domain);
|
||||
$len = count($domain);
|
||||
if ($len == 1) {
|
||||
return $domain[0];
|
||||
}
|
||||
$extract = new Extract();
|
||||
$result = $extract->parse($url);
|
||||
|
||||
$domain = $domain[$len - 2].'.'.$domain[$len - 1];
|
||||
|
||||
return $domain;
|
||||
return $result->getRegistrableDomain();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user