Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更改 跨应用生成URL会携带当前入口文件 #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ public function build()
$depr = $this->route->config('pathinfo_depr');
$url = str_replace('/', $depr, $url);

$file = $request->baseFile();
if ($file && 0 !== strpos($request->url(), $file)) {
$file = str_replace('\\', '/', dirname($file));
}
// 如不指定入口文件 即为当前入口文件
if(empty($this->root)){
$file = $request->baseFile();
if ($file && 0 !== strpos($request->url(), $file)) {
$file = str_replace('\\', '/', dirname($file));
}

$url = rtrim($file, '/') . '/' . ltrim($url, '/');
$url = rtrim($file, '/') . '/' . ltrim($url, '/');
}

// URL后缀
if ('/' == substr($url, -1) || '' == $url) {
Expand Down