File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change 11
11
}
12
12
});
13
13
14
- Route::get ('/mary/asset ' , function (Request $ request ) {
15
- if ($ request ->name ) {
16
- $ extension = Str::of ($ request ->name )->afterLast ('. ' )->toString ();
14
+ Route::middleware ('cache.headers:public;max_age=2628000;etag ' )->get ('/mary/asset ' , function (Request $ request ) {
15
+ if (! $ request ->name ) {
16
+ abort (404 );
17
+ }
18
+
19
+ if (Str::of ($ request ->name )->contains ('.. ' )) {
20
+ abort (404 );
21
+ }
17
22
18
- $ type = match ($ extension ) {
19
- 'js ' => 'application/javascript ' ,
20
- 'css ' => 'text/css ' ,
21
- default => 'text/html '
22
- };
23
+ $ file = Str::of ($ request ->name )->before ('? ' )->toString ();
23
24
24
- return response (File::get (__DIR__ . "/../libs/ {$ request ->name }" ))->header ('Content-Type ' , $ type );
25
+ if (! File::exists (__DIR__ . "/../libs/ {$ file }" )) {
26
+ abort (404 );
25
27
}
26
28
27
- abort (404 );
29
+ $ extension = Str::of ($ file )->afterLast ('. ' )->toString ();
30
+
31
+ $ type = match ($ extension ) {
32
+ 'js ' => 'application/javascript ' ,
33
+ 'css ' => 'text/css ' ,
34
+ default => 'text/html '
35
+ };
36
+
37
+ return response (File::get (__DIR__ . "/../libs/ {$ file }" ))->withHeaders ([
38
+ 'Content-Type ' => $ type ,
39
+ ]);
28
40
});
You can’t perform that action at this time.
0 commit comments