From c8015228eed9ef0b4346c1b57bfdfaa0df1f98d8 Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 13 Sep 2017 10:10:06 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8URL=E6=A0=B9=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/hook/FilterView.php | 2 +- extend/service/FileService.php | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/extend/hook/FilterView.php b/extend/hook/FilterView.php index 92319644f..b38817bf9 100644 --- a/extend/hook/FilterView.php +++ b/extend/hook/FilterView.php @@ -40,7 +40,7 @@ class FilterView { $this->request = Request::instance(); list($appRoot, $uriSelf) = [$this->request->root(true), $this->request->url(true)]; - $uriRoot = strpos($appRoot, EXT) ? ltrim(dirname($appRoot), DS) : $appRoot; + $uriRoot = preg_match('/\.php$/', $appRoot) ? dirname($appRoot) : $appRoot; $uriStatic = "{$uriRoot}/static"; $replace = ['__APP__' => $appRoot, '__SELF__' => $uriSelf, '__PUBLIC__' => $uriRoot, '__STATIC__' => $uriStatic]; $params = str_replace(array_keys($replace), array_values($replace), $params); diff --git a/extend/service/FileService.php b/extend/service/FileService.php index 2fde733fe..bbd3446ee 100644 --- a/extend/service/FileService.php +++ b/extend/service/FileService.php @@ -131,13 +131,9 @@ class FileService */ public static function getBaseUriLocal() { - $request = request(); - $base = $request->root(); - $root = strpos($base, '.') ? ltrim(dirname($base), DS) : $base; - if ('' != $root) { - $root = '/' . ltrim($root, '/'); - } - return ($request->isSsl() ? 'https' : 'http') . '://' . $request->host() . "{$root}/static/upload/"; + $appRoot = request()->root(true); + $uriRoot = preg_match('/\.php$/', $appRoot) ? dirname($appRoot) : $appRoot; + return "{$uriRoot}/static/upload/"; } /**