refactor: BackUrl::selfWithoutBack 统一 selfWithoutBack 构造并修复 currentQuery 依赖

This commit is contained in:
萝卜
2026-03-14 18:52:28 +00:00
parent b759a87a57
commit 956e177544
6 changed files with 24 additions and 26 deletions

View File

@@ -7,12 +7,10 @@
@php
// back 参数用于“返回上一页(保留上下文)”,但 back 本身不应再包含 back避免无限嵌套导致 URL 膨胀)
// 注意:使用相对路径而非绝对 URL避免不同 APP_URL 环境影响,以及 show 页 back 安全校验(要求以 / 开头)
$selfWithoutBack = \App\Support\BackUrl::selfWithoutBack();
$currentQuery = request()->query();
unset($currentQuery['back']);
$selfWithoutBack = '/' . ltrim(request()->path(), '/');
if (count($currentQuery) > 0) {
$selfWithoutBack .= '?' . \Illuminate\Support\Arr::query($currentQuery);
}
$back = $selfWithoutBack;
// 用于构建“保留当前筛选上下文”的站内跳转链接(且不透传 back避免嵌套/污染)