refactor: BackUrl::selfWithoutBack 统一 selfWithoutBack 构造并修复 currentQuery 依赖
This commit is contained in:
@@ -133,4 +133,21 @@ class BackUrl
|
||||
|
||||
return $path . '?' . \Illuminate\Support\Arr::query($q);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成当前页面去掉 back 后的 selfWithoutBack(站内相对路径)。
|
||||
* 用于:生成返回来源 back 或防止 back 嵌套膨胀。
|
||||
*/
|
||||
public static function selfWithoutBack(): string
|
||||
{
|
||||
$currentQuery = request()->query();
|
||||
unset($currentQuery['back']);
|
||||
|
||||
$url = '/' . ltrim(request()->path(), '/');
|
||||
if (count($currentQuery) > 0) {
|
||||
$url .= '?' . \Illuminate\Support\Arr::query($currentQuery);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user