File tree Expand file tree Collapse file tree 4 files changed +28
-25
lines changed Expand file tree Collapse file tree 4 files changed +28
-25
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ protected $middleware = [
44
44
<td><strong>Description</strong></td>
45
45
<td><strong>Available</strong></td>
46
46
<tr>
47
+ <tr>
48
+ <td>remove_quotes</td>
49
+ <td>Removes unnecessary quotes in HTML tags</td>
50
+ <td>YES</td>
51
+ <tr>
47
52
<tr>
48
53
<td>trim_urls</td>
49
54
<td>Removes unnecessary prefixes from URLs</td>
@@ -194,11 +199,6 @@ protected $middleware = [
194
199
<td>Instruments the page, inlines its critical CSS at the top, and lazily loads the rest</td>
195
200
<td>NO</td>
196
201
<tr>
197
- <tr>
198
- <td>remove_quotes</td>
199
- <td>Removes unnecessary quotes in HTML tags</td>
200
- <td>NO</td>
201
- <tr>
202
202
<tr>
203
203
<td>resize_mobile_images</td>
204
204
<td>Just like inline_preview_images, but uses smaller placeholder images for mobile browsers</td>
Original file line number Diff line number Diff line change 2
2
3
3
namespace RenatoMarinho \LaravelPageSpeed \Middleware ;
4
4
5
- use Closure ;
6
-
7
- class RemoveQuotes
5
+ class RemoveQuotes extends PageSpeed
8
6
{
9
- /**
10
- * Handle an incoming request.
11
- *
12
- * @param \Illuminate\Http\Request $request
13
- * @param \Closure $next
14
- * @return mixed
15
- */
16
-
17
- public function handle ($ request , Closure $ next )
7
+ public function apply ($ buffer )
18
8
{
19
- }
9
+ $ replace = [
10
+ '/src="(.*?)"/ ' => 'src=$1 ' ,
11
+ '/width="(.*?)"/ ' => 'width=$1 ' ,
12
+ '/height="(.*?)"/ ' => 'height=$1 ' ,
13
+ '/name="(.*?)"/ ' => 'name=$1 ' ,
14
+ '/charset="(.*?)"/ ' => 'charset=$1 ' ,
15
+ '/href="(.*?)"/ ' => 'href=$1 ' ,
16
+ '/align="(.*?)"/ ' => 'align=$1 ' ,
17
+ '/border="(.*?)"/ ' => 'border=$1 ' ,
18
+ '/crossorigin="(.*?)"/ ' => 'crossorigin=$1 ' ,
19
+ '/rel="(.*?)"/ ' => 'rel=$1 ' ,
20
+ ];
20
21
22
+ return $ this ->replace ($ replace , $ buffer );
23
+ }
21
24
}
Original file line number Diff line number Diff line change 5
5
use RenatoMarinho \LaravelPageSpeed \Middleware \RemoveComments ;
6
6
use RenatoMarinho \LaravelPageSpeed \Test \TestCase ;
7
7
8
- class CollapseWhitespaceTest extends TestCase
8
+ class RemoveCommentsTest extends TestCase
9
9
{
10
10
public $ middleware ;
11
11
Original file line number Diff line number Diff line change 2
2
3
3
namespace RenatoMarinho \LaravelPageSpeed \Test \Middleware ;
4
4
5
- use RenatoMarinho \LaravelPageSpeed \Middleware \TrimUrls ;
5
+ use RenatoMarinho \LaravelPageSpeed \Middleware \RemoveQuotes ;
6
6
use RenatoMarinho \LaravelPageSpeed \Test \TestCase ;
7
7
8
- class TrimUrlsTest extends TestCase
8
+ class RemoveQuotesTest extends TestCase
9
9
{
10
10
public $ middleware ;
11
11
12
12
public function getMiddleware ()
13
13
{
14
- $ this ->middleware = new TrimUrls ();
14
+ $ this ->middleware = new RemoveQuotes ();
15
15
}
16
16
17
17
public function testApply ()
18
18
{
19
19
$ html = $ this ->middleware ->apply ($ this ->html );
20
20
21
- $ this ->assertNotContains ( " https:// " , $ html );
22
- $ this ->assertNotContains ( " http:// " , $ html );
23
- $ this ->assertContains (" //code.jquery. com/jquery-3.2.1.min.js " , $ html );
21
+ $ this ->assertContains ( ' <link rel=apple-touch-icon href=icon.png> ' , $ html );
22
+ $ this ->assertContains ( ' <meta charset=utf-8> ' , $ html );
23
+ $ this ->assertContains (' <img src=http://emblemsbf. com/img/18346.jpg width=250 style="height:300px; padding:10px" /> ' , $ html );
24
24
}
25
25
}
You can’t perform that action at this time.
0 commit comments