Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/think/route/Url.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: phpdoc_separation

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: yoda_style

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: phpdoc_summary

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: global_namespace_import

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: phpdoc_types_order

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: ordered_types

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: blank_line_after_opening_tag

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: no_superfluous_phpdoc_tags

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: phpdoc_no_access

Check warning on line 1 in src/think/route/Url.php

View workflow job for this annotation

GitHub Actions / php-cs-fixer

Found violation(s) of type: no_superfluous_elseif
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
Expand Down Expand Up @@ -224,6 +224,11 @@
}
}

$ext = pathinfo($url, PATHINFO_EXTENSION);
if ('' !== $ext && str_ends_with($url, '.' . $ext)) {
$url = substr($url, 0, -strlen($ext) - 1);
}

return $url;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/UrlRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ public function testUrlDispatch()
$this->assertEquals('bar', $response->getContent());
}

/**
* 测试 Route::buildUrl()
*/
public function testBuild()
{
$request = $this->makeRequest('index/index.html');

$this->app->request = $request;

$urlBuild = new \think\route\Url($this->route, $this->app, '', []);
$result = $urlBuild->build();

$this->assertEquals('/index/index.html', $result);
}

/**
* @param $path
* @param string $method
Expand Down
Loading