File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 33namespace GNAHotelSolutions \LaravelTrailingSlash \Routing ;
44
55use Illuminate \Routing \UrlGenerator ;
6+ use Illuminate \Support \Str ;
67
78class TrailingSlashUrlGenerator extends UrlGenerator
89{
@@ -17,10 +18,20 @@ class TrailingSlashUrlGenerator extends UrlGenerator
1718 */
1819 public function format ($ root , $ path , $ route = '' )
1920 {
20- if (! config ( ' laravel-trailing-slash.active ' , false )) {
21+ if ($ this -> pathIsFile ( $ path ) || $ this -> packageIsDisabled ( )) {
2122 return parent ::format ($ root , $ path , $ route );
2223 }
2324
2425 return parent ::format ($ root , $ path , $ route ) . '/ ' ;
2526 }
27+
28+ private function pathIsFile ($ path ): bool
29+ {
30+ return Str::contains (Str::afterLast ($ path , '/ ' ), '. ' );
31+ }
32+
33+ private function packageIsDisabled (): bool
34+ {
35+ return ! config ('laravel-trailing-slash.active ' , false );
36+ }
2637}
You can’t perform that action at this time.
0 commit comments