diff --git a/README.md b/README.md index eb28334..73e2c73 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,16 @@ You can install the package via composer: $ composer require renatomarinho/laravel-page-speed ``` -Next, the \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class - middleware must be registered in the kernel: +Next, the \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class and others - middleware must be registered in the kernel: ```php //app/Http/Kernel.php protected $middleware = [ ... - \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class + \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class, + \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class, + \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class, ] ``` @@ -37,6 +39,11 @@ protected $middleware = [ ## Roadmap : Filters + + + + + @@ -237,11 +244,7 @@ protected $middleware = [ - - - - - +
trim_urlsRemoves unnecessary prefixes from URLsYES
Name DescriptionSprites images NO
trim_urlsRemoves unnecessary prefixes from URLsNO

diff --git a/composer.json b/composer.json index 91547c1..77f7cd7 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,10 @@ "php": ">=5.6", "illuminate/support": "5.3.x|5.4.x|5.5.x" }, + "require-dev": { + "phpunit/phpunit": "^6.2", + "orchestra/testbench": "~3.2" + }, "autoload": { "psr-4": { "RenatoMarinho\\LaravelPageSpeed\\": "src/" @@ -29,11 +33,6 @@ "RenatoMarinho\\LaravelPageSpeed\\Test\\": "tests" } }, - "require-dev": { - "phpunit/phpunit": "^4.8|^5.2", - "orchestra/testbench": "3.x", - "squizlabs/php_codesniffer": "^2.3" - }, "scripts": { "test": "phpunit", "check-style": "phpcs -p --standard=PSR2 src/", @@ -41,4 +40,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index c460f53..75244be 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "443bd20907d6869d919dab5c677bb345", - "content-hash": "033db9f291c04e23392d51e37001deff", + "hash": "d012733502925a826a4d8023f16a8295", + "content-hash": "273af42f45cd725d67cae86abca4ba1c", "packages": [ { "name": "doctrine/inflector", @@ -600,16 +600,16 @@ }, { "name": "ramsey/uuid", - "version": "3.7.0", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "0ef23d1b10cf1bc576e9d865a7e9c47982c5715e" + "reference": "45cffe822057a09e05f7bd09ec5fb88eeecd2334" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/0ef23d1b10cf1bc576e9d865a7e9c47982c5715e", - "reference": "0ef23d1b10cf1bc576e9d865a7e9c47982c5715e", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/45cffe822057a09e05f7bd09ec5fb88eeecd2334", + "reference": "45cffe822057a09e05f7bd09ec5fb88eeecd2334", "shasum": "" }, "require": { @@ -678,7 +678,7 @@ "identifier", "uuid" ], - "time": "2017-08-04 13:39:04" + "time": "2017-09-22 20:46:04" }, { "name": "swiftmailer/swiftmailer", @@ -736,16 +736,16 @@ }, { "name": "symfony/console", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6" + "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d6596cb5022b6a0bd940eae54a1de78646a5fda6", - "reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6", + "url": "https://api.github.com/repos/symfony/console/zipball/a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", + "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", "shasum": "" }, "require": { @@ -800,11 +800,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-08-27 14:52:21" + "time": "2017-09-06 16:40:18" }, { "name": "symfony/css-selector", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -857,16 +857,16 @@ }, { "name": "symfony/debug", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d" + "reference": "8beb24eec70b345c313640962df933499373a944" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/084d804fe35808eb2ef596ec83d85d9768aa6c9d", - "reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d", + "url": "https://api.github.com/repos/symfony/debug/zipball/8beb24eec70b345c313640962df933499373a944", + "reference": "8beb24eec70b345c313640962df933499373a944", "shasum": "" }, "require": { @@ -909,11 +909,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-08-27 14:52:21" + "time": "2017-09-01 13:23:39" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -976,7 +976,7 @@ }, { "name": "symfony/finder", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -1025,16 +1025,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "14bacad23a4f075bfd3fd456755236cb261320e3" + "reference": "2cdc7de1921d1a1c805a13dc05e44a2cd58f5ad3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/14bacad23a4f075bfd3fd456755236cb261320e3", - "reference": "14bacad23a4f075bfd3fd456755236cb261320e3", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/2cdc7de1921d1a1c805a13dc05e44a2cd58f5ad3", + "reference": "2cdc7de1921d1a1c805a13dc05e44a2cd58f5ad3", "shasum": "" }, "require": { @@ -1074,20 +1074,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2017-08-10 07:07:06" + "time": "2017-09-06 17:07:39" }, { "name": "symfony/http-kernel", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "1c1717d28904744dc9a9f6a9d97a8b9bed1680e9" + "reference": "70f5bb3cdd737624249953b61023411e26be5db7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/1c1717d28904744dc9a9f6a9d97a8b9bed1680e9", - "reference": "1c1717d28904744dc9a9f6a9d97a8b9bed1680e9", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/70f5bb3cdd737624249953b61023411e26be5db7", + "reference": "70f5bb3cdd737624249953b61023411e26be5db7", "shasum": "" }, "require": { @@ -1160,7 +1160,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2017-08-28 22:35:03" + "time": "2017-09-11 16:13:23" }, { "name": "symfony/polyfill-mbstring", @@ -1223,7 +1223,7 @@ }, { "name": "symfony/process", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -1272,7 +1272,7 @@ }, { "name": "symfony/routing", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", @@ -1350,7 +1350,7 @@ }, { "name": "symfony/translation", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", @@ -1415,7 +1415,7 @@ }, { "name": "symfony/var-dumper", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", @@ -1728,22 +1728,22 @@ }, { "name": "orchestra/testbench", - "version": "v3.4.8", + "version": "v3.4.9", "source": { "type": "git", "url": "https://github.com/orchestral/testbench.git", - "reference": "954b15e551e53f0c6d3ce02dfab6b890288e5164" + "reference": "e885dc64dfefb5797c1680367e8b3e2f669910b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/testbench/zipball/954b15e551e53f0c6d3ce02dfab6b890288e5164", - "reference": "954b15e551e53f0c6d3ce02dfab6b890288e5164", + "url": "https://api.github.com/repos/orchestral/testbench/zipball/e885dc64dfefb5797c1680367e8b3e2f669910b3", + "reference": "e885dc64dfefb5797c1680367e8b3e2f669910b3", "shasum": "" }, "require": { "fzaninotto/faker": "~1.4", "laravel/framework": "~5.4.17", - "orchestra/testbench-core": "~3.4.0", + "orchestra/testbench-core": "~3.4.2", "php": ">=5.6.0" }, "require-dev": { @@ -1784,20 +1784,20 @@ "orchestral", "testing" ], - "time": "2017-07-03 15:48:06" + "time": "2017-09-18 22:59:48" }, { "name": "orchestra/testbench-core", - "version": "v3.4.1", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/orchestral/testbench-core.git", - "reference": "2a5bafeaac992c4c89da371f5bdd76cb99abb837" + "reference": "f3f615f02fa4c8be972952f954f83cbadae69e41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/testbench-core/zipball/2a5bafeaac992c4c89da371f5bdd76cb99abb837", - "reference": "2a5bafeaac992c4c89da371f5bdd76cb99abb837", + "url": "https://api.github.com/repos/orchestral/testbench-core/zipball/f3f615f02fa4c8be972952f954f83cbadae69e41", + "reference": "f3f615f02fa4c8be972952f954f83cbadae69e41", "shasum": "" }, "require": { @@ -1849,20 +1849,122 @@ "orchestral", "testing" ], - "time": "2017-08-19 03:07:38" + "time": "2017-09-18 22:58:34" + }, + { + "name": "phar-io/manifest", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^1.0.1", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2017-03-05 18:14:27" + }, + { + "name": "phar-io/version", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2017-03-05 17:38:23" }, { "name": "phpdocumentor/reflection-common", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { @@ -1903,7 +2005,7 @@ "reflection", "static analysis" ], - "time": "2015-12-27 11:43:31" + "time": "2017-09-11 18:02:19" }, { "name": "phpdocumentor/reflection-docblock", @@ -2062,40 +2164,41 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.8", + "version": "5.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b", + "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" + "php": "^7.0", + "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^1.4.11 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" + "ext-xdebug": "^2.5", + "phpunit/phpunit": "^6.0" }, "suggest": { - "ext-xdebug": "^2.5.1" + "ext-xdebug": "^2.5.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "5.2.x-dev" } }, "autoload": { @@ -2121,7 +2224,7 @@ "testing", "xunit" ], - "time": "2017-04-02 07:44:40" + "time": "2017-08-03 12:40:43" }, { "name": "phpunit/php-file-iterator", @@ -2311,16 +2414,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.7.21", + "version": "6.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3b91adfb64264ddec5a2dee9851f354aa66327db" + "reference": "9501bab711403a1ab5b8378a8adb4ec3db3debdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3b91adfb64264ddec5a2dee9851f354aa66327db", - "reference": "3b91adfb64264ddec5a2dee9851f354aa66327db", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9501bab711403a1ab5b8378a8adb4ec3db3debdb", + "reference": "9501bab711403a1ab5b8378a8adb4ec3db3debdb", "shasum": "" }, "require": { @@ -2329,33 +2432,35 @@ "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.4", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "myclabs/deep-copy": "^1.6.1", + "phar-io/manifest": "^1.0.1", + "phar-io/version": "^1.0", + "php": "^7.0", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^5.2.2", + "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^1.0.9", + "phpunit/phpunit-mock-objects": "^4.0.3", + "sebastian/comparator": "^2.0.2", + "sebastian/diff": "^2.0", + "sebastian/environment": "^3.1", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^1.0", + "sebastian/version": "^2.0.1" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" + "phpdocumentor/reflection-docblock": "3.0.2", + "phpunit/dbunit": "<3.0" }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" + "phpunit/php-invoker": "^1.1" }, "bin": [ "phpunit" @@ -2363,7 +2468,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "6.3.x-dev" } }, "autoload": { @@ -2389,33 +2494,33 @@ "testing", "xunit" ], - "time": "2017-06-21 08:11:54" + "time": "2017-08-04 05:20:39" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.4.4", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" + "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", + "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" + "doctrine/instantiator": "^1.0.5", + "php": "^7.0", + "phpunit/php-text-template": "^1.2.1", + "sebastian/exporter": "^3.0" }, "conflict": { - "phpunit/phpunit": "<5.4.0" + "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^5.4" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-soap": "*" @@ -2423,7 +2528,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2.x-dev" + "dev-master": "4.0.x-dev" } }, "autoload": { @@ -2448,7 +2553,7 @@ "mock", "xunit" ], - "time": "2017-06-30 09:13:00" + "time": "2017-08-03 14:08:16" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2497,30 +2602,30 @@ }, { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/ae068fede81d06e7bb9bb46a367210a3d3e1fe6a", + "reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.0", + "sebastian/diff": "^2.0", + "sebastian/exporter": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -2557,32 +2662,32 @@ "compare", "equality" ], - "time": "2017-01-29 09:50:25" + "time": "2017-08-03 07:14:59" }, { "name": "sebastian/diff", - "version": "1.4.3", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", + "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2609,32 +2714,32 @@ "keywords": [ "diff" ], - "time": "2017-05-22 07:24:03" + "time": "2017-08-03 08:09:46" }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -2659,34 +2764,34 @@ "environment", "hhvm" ], - "time": "2016-11-26 07:53:53" + "time": "2017-07-01 08:51:00" }, { "name": "sebastian/exporter", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -2726,27 +2831,27 @@ "export", "exporter" ], - "time": "2016-11-19 08:54:04" + "time": "2017-04-03 13:19:02" }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" @@ -2754,7 +2859,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2777,33 +2882,34 @@ "keywords": [ "global state" ], - "time": "2015-10-12 03:26:01" + "time": "2017-04-27 15:39:26" }, { "name": "sebastian/object-enumerator", - "version": "2.0.1", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2823,32 +2929,77 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-02-18 15:18:39" + "time": "2017-08-03 12:35:26" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29 09:07:27" }, { "name": "sebastian/recursion-context", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2876,7 +3027,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19 07:33:16" + "time": "2017-03-03 06:23:57" }, { "name": "sebastian/resource-operations", @@ -2964,63 +3115,29 @@ "time": "2016-10-03 07:35:21" }, { - "name": "squizlabs/php_codesniffer", - "version": "2.9.1", + "name": "theseer/tokenizer", + "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" + "url": "https://github.com/theseer/tokenizer.git", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", "shasum": "" }, "require": { - "ext-simplexml": "*", + "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" + "php": "^7.0" }, - "bin": [ - "scripts/phpcs", - "scripts/phpcbf" - ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, "autoload": { "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -3029,72 +3146,13 @@ ], "authors": [ { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2017-05-22 02:43:20" - }, - { - "name": "symfony/yaml", - "version": "v3.3.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "1d8c2a99c80862bdc3af94c1781bf70f86bccac0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/1d8c2a99c80862bdc3af94c1781bf70f86bccac0", - "reference": "1d8c2a99c80862bdc3af94c1781bf70f86bccac0", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "require-dev": { - "symfony/console": "~2.8|~3.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" } ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2017-07-29 21:54:42" + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2017-04-07 12:08:54" }, { "name": "webmozart/assert", diff --git a/config/laravel-page-speed.php b/config/laravel-page-speed.php index 6c4c371..67b0056 100644 --- a/config/laravel-page-speed.php +++ b/config/laravel-page-speed.php @@ -9,6 +9,7 @@ */ 'zlib' => false, // Needs enable zlib module: http://php.net/manual/en/zlib.configuration.php + //ini_set('zlib.output_compression', 'On'); 'filters' => [ 'collapse_whitespace' => true, diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..032cfa6 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + tests + + + + + src + + + diff --git a/src/Middleware/CollapseWhitespace.php b/src/Middleware/CollapseWhitespace.php index 3a1e47c..c1f0038 100644 --- a/src/Middleware/CollapseWhitespace.php +++ b/src/Middleware/CollapseWhitespace.php @@ -2,33 +2,11 @@ namespace RenatoMarinho\LaravelPageSpeed\Middleware; -use Closure, Config; - -class CollapseWhitespace +class CollapseWhitespace extends PageSpeed { - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed - */ - - public function handle($request, Closure $next) - { - $response = $next($request); - //ini_set('zlib.output_compression', 'On'); - - return $this->html($response); - } - - public function html($response) + public function apply($buffer) { - $buffer = $response->getContent(); - $replace = [ - '//s' => '', - "/<\?php/" => ' '$1', "/\r/" => '', "/\n/" => '', @@ -37,21 +15,6 @@ public function html($response) "/> + '><', ]; - if(strpos($buffer,'
') !== false) {
-            $replace = [
-                '//s' => '',
-                "/<\?php/" => ' '',
-                "/>\n '><',
-                "/>\s+\n '><',
-                "/>\n\s+ '><',
-            ];
-        }
-
-        $buffer = preg_replace(array_keys($replace), array_values($replace), $buffer);
-
-        $response->setContent($buffer);
-
-        return $response;
+        return $this->replace($replace, $buffer);
     }
 }
\ No newline at end of file
diff --git a/src/Middleware/PageSpeed.php b/src/Middleware/PageSpeed.php
new file mode 100644
index 0000000..1d75537
--- /dev/null
+++ b/src/Middleware/PageSpeed.php
@@ -0,0 +1,30 @@
+getContent();
+        $newContent = $this->apply($html);
+
+        return $response->setContent($newContent);
+    }
+
+    protected function replace(array $replace, string $buffer) : string
+    {
+        return preg_replace(array_keys($replace), array_values($replace), $buffer);
+    }
+}
\ No newline at end of file
diff --git a/src/Middleware/RemoveComments.php b/src/Middleware/RemoveComments.php
index 2d3f6df..cbd35d9 100644
--- a/src/Middleware/RemoveComments.php
+++ b/src/Middleware/RemoveComments.php
@@ -2,20 +2,15 @@
 
 namespace RenatoMarinho\LaravelPageSpeed\Middleware;
 
-use Closure;
 
-class RemoveComments
+class RemoveComments extends PageSpeed
 {
-    /**
-     * Handle an incoming request.
-     *
-     * @param  \Illuminate\Http\Request $request
-     * @param  \Closure $next
-     * @return mixed
-     */
-
-    public function handle($request, Closure $next)
+    public function apply($buffer)
     {
-    }
+        $replace = [
+            '//s' => ''
+        ];
 
+        return $this->replace($replace, $buffer);
+    }
 }
\ No newline at end of file
diff --git a/src/Middleware/TrimUrls.php b/src/Middleware/TrimUrls.php
index fa7f891..947e948 100644
--- a/src/Middleware/TrimUrls.php
+++ b/src/Middleware/TrimUrls.php
@@ -2,20 +2,15 @@
 
 namespace RenatoMarinho\LaravelPageSpeed\Middleware;
 
-use Closure;
-
-class TrimUrls
+class TrimUrls extends PageSpeed
 {
-    /**
-     * Handle an incoming request.
-     *
-     * @param  \Illuminate\Http\Request $request
-     * @param  \Closure $next
-     * @return mixed
-     */
-
-    public function handle($request, Closure $next)
+    public function apply($buffer)
     {
-    }
+        $replace = [
+            '/https:/' => '',
+            '/http:/' => ''
+        ];
 
+        return $this->replace($replace, $buffer);
+    }
 }
\ No newline at end of file
diff --git a/tests/Boilerplate/404.html b/tests/Boilerplate/404.html
new file mode 100644
index 0000000..778d7ea
--- /dev/null
+++ b/tests/Boilerplate/404.html
@@ -0,0 +1,60 @@
+
+
+
+    
+    Page Not Found
+    
+    
+
+
+    

Page Not Found

+

Sorry, but the page you were trying to view does not exist.

+ + + diff --git a/tests/Boilerplate/LICENSE.txt b/tests/Boilerplate/LICENSE.txt new file mode 100644 index 0000000..294e91d --- /dev/null +++ b/tests/Boilerplate/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) HTML5 Boilerplate + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tests/Boilerplate/css/main.css b/tests/Boilerplate/css/main.css new file mode 100644 index 0000000..46098cf --- /dev/null +++ b/tests/Boilerplate/css/main.css @@ -0,0 +1,291 @@ +/*! HTML5 Boilerplate v6.0.1 | MIT License | https://html5boilerplate.com/ */ + +/* + * What follows is the result of much research on cross-browser styling. + * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal, + * Kroc Camen, and the H5BP dev community and team. + */ + +/* ========================================================================== + Base styles: opinionated defaults + ========================================================================== */ + +html { + color: #222; + font-size: 1em; + line-height: 1.4; +} + +/* + * Remove text-shadow in selection highlight: + * https://twitter.com/miketaylr/status/12228805301 + * + * Vendor-prefixed and regular ::selection selectors cannot be combined: + * https://stackoverflow.com/a/16982510/7133471 + * + * Customize the background color to match your design. + */ + +::-moz-selection { + background: #b3d4fc; + text-shadow: none; +} + +::selection { + background: #b3d4fc; + text-shadow: none; +} + +/* + * A better looking default horizontal rule + */ + +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #ccc; + margin: 1em 0; + padding: 0; +} + +/* + * Remove the gap between audio, canvas, iframes, + * images, videos and the bottom of their containers: + * https://github.com/h5bp/html5-boilerplate/issues/440 + */ + +audio, +canvas, +iframe, +img, +svg, +video { + vertical-align: middle; +} + +/* + * Remove default fieldset styles. + */ + +fieldset { + border: 0; + margin: 0; + padding: 0; +} + +/* + * Allow only vertical resizing of textareas. + */ + +textarea { + resize: vertical; +} + +/* ========================================================================== + Browser Upgrade Prompt + ========================================================================== */ + +.browserupgrade { + margin: 0.2em 0; + background: #ccc; + color: #000; + padding: 0.2em 0; +} + +/* ========================================================================== + Author's custom styles + ========================================================================== */ + + + + + + + + + + + + + + + + + +/* ========================================================================== + Helper classes + ========================================================================== */ + +/* + * Hide visually and from screen readers + */ + +.hidden { + display: none !important; +} + +/* + * Hide only visually, but have it available for screen readers: + * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility + * + * 1. For long content, line feeds are not interpreted as spaces and small width + * causes content to wrap 1 word per line: + * https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe + */ + +.visuallyhidden { + border: 0; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + white-space: nowrap; /* 1 */ +} + +/* + * Extends the .visuallyhidden class to allow the element + * to be focusable when navigated to via the keyboard: + * https://www.drupal.org/node/897638 + */ + +.visuallyhidden.focusable:active, +.visuallyhidden.focusable:focus { + clip: auto; + -webkit-clip-path: none; + clip-path: none; + height: auto; + margin: 0; + overflow: visible; + position: static; + width: auto; + white-space: inherit; +} + +/* + * Hide visually and from screen readers, but maintain layout + */ + +.invisible { + visibility: hidden; +} + +/* + * Clearfix: contain floats + * + * For modern browsers + * 1. The space content is one way to avoid an Opera bug when the + * `contenteditable` attribute is included anywhere else in the document. + * Otherwise it causes space to appear at the top and bottom of elements + * that receive the `clearfix` class. + * 2. The use of `table` rather than `block` is only necessary if using + * `:before` to contain the top-margins of child elements. + */ + +.clearfix:before, +.clearfix:after { + content: " "; /* 1 */ + display: table; /* 2 */ +} + +.clearfix:after { + clear: both; +} + +/* ========================================================================== + EXAMPLE Media Queries for Responsive Design. + These examples override the primary ('mobile first') styles. + Modify as content requires. + ========================================================================== */ + +@media only screen and (min-width: 35em) { + /* Style adjustments for viewports that meet the condition */ +} + +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 1.25dppx), + (min-resolution: 120dpi) { + /* Style adjustments for high resolution devices */ +} + +/* ========================================================================== + Print styles. + Inlined to avoid the additional HTTP request: + http://www.phpied.com/delay-loading-your-print-css/ + ========================================================================== */ + +@media print { + *, + *:before, + *:after { + background: transparent !important; + color: #000 !important; /* Black prints faster: + http://www.sanbeiji.com/archives/953 */ + box-shadow: none !important; + text-shadow: none !important; + } + + a, + a:visited { + text-decoration: underline; + } + + a[href]:after { + content: " (" attr(href) ")"; + } + + abbr[title]:after { + content: " (" attr(title) ")"; + } + + /* + * Don't show links that are fragment identifiers, + * or use the `javascript:` pseudo protocol + */ + + a[href^="#"]:after, + a[href^="javascript:"]:after { + content: ""; + } + + pre { + white-space: pre-wrap !important; + } + pre, + blockquote { + border: 1px solid #999; + page-break-inside: avoid; + } + + /* + * Printing Tables: + * http://css-discuss.incutio.com/wiki/Printing_Tables + */ + + thead { + display: table-header-group; + } + + tr, + img { + page-break-inside: avoid; + } + + p, + h2, + h3 { + orphans: 3; + widows: 3; + } + + h2, + h3 { + page-break-after: avoid; + } +} diff --git a/tests/Boilerplate/css/normalize.css b/tests/Boilerplate/css/normalize.css new file mode 100644 index 0000000..fa4e73d --- /dev/null +++ b/tests/Boilerplate/css/normalize.css @@ -0,0 +1,447 @@ +/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */ + +/* Document + ========================================================================== */ + +/** + * 1. Correct the line height in all browsers. + * 2. Prevent adjustments of font size after orientation changes in + * IE on Windows Phone and in iOS. + */ + +html { + line-height: 1.15; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/* Sections + ========================================================================== */ + +/** + * Remove the margin in all browsers (opinionated). + */ + +body { + margin: 0; +} + +/** + * Add the correct display in IE 9-. + */ + +article, +aside, +footer, +header, +nav, +section { + display: block; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/* Grouping content + ========================================================================== */ + +/** + * Add the correct display in IE 9-. + * 1. Add the correct display in IE. + */ + +figcaption, +figure, +main { /* 1 */ + display: block; +} + +/** + * Add the correct margin in IE 8. + */ + +figure { + margin: 1em 40px; +} + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/* Text-level semantics + ========================================================================== */ + +/** + * 1. Remove the gray background on active links in IE 10. + * 2. Remove gaps in links underline in iOS 8+ and Safari 8+. + */ + +a { + background-color: transparent; /* 1 */ + -webkit-text-decoration-skip: objects; /* 2 */ +} + +/** + * 1. Remove the bottom border in Chrome 57- and Firefox 39-. + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Prevent the duplicate application of `bolder` by the next rule in Safari 6. + */ + +b, +strong { + font-weight: inherit; +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct font style in Android 4.3-. + */ + +dfn { + font-style: italic; +} + +/** + * Add the correct background and color in IE 9-. + */ + +mark { + background-color: #ff0; + color: #000; +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Add the correct display in IE 9-. + */ + +audio, +video { + display: inline-block; +} + +/** + * Add the correct display in iOS 4-7. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Remove the border on images inside links in IE 10-. + */ + +img { + border-style: none; +} + +/** + * Hide the overflow in IE. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change the font styles in all browsers (opinionated). + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font-family: sans-serif; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video` + * controls in Android 4. + * 2. Correct the inability to style clickable types in iOS and Safari. + */ + +button, +html [type="button"], /* 1 */ +[type="reset"], +[type="submit"] { + -webkit-appearance: button; /* 2 */ +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Correct the padding in Firefox. + */ + +fieldset { + padding: 0.35em 0.75em 0.625em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * 1. Add the correct display in IE 9-. + * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Remove the default vertical scrollbar in IE. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10-. + * 2. Remove the padding in IE 10-. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding and cancel buttons in Chrome and Safari on macOS. + */ + +[type="search"]::-webkit-search-cancel-button, +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + +/* Interactive + ========================================================================== */ + +/* + * Add the correct display in IE 9-. + * 1. Add the correct display in Edge, IE, and Firefox. + */ + +details, /* 1 */ +menu { + display: block; +} + +/* + * Add the correct display in all browsers. + */ + +summary { + display: list-item; +} + +/* Scripting + ========================================================================== */ + +/** + * Add the correct display in IE 9-. + */ + +canvas { + display: inline-block; +} + +/** + * Add the correct display in IE. + */ + +template { + display: none; +} + +/* Hidden + ========================================================================== */ + +/** + * Add the correct display in IE 10-. + */ + +[hidden] { + display: none; +} diff --git a/tests/Boilerplate/favicon.ico b/tests/Boilerplate/favicon.ico new file mode 100644 index 0000000..be74abd Binary files /dev/null and b/tests/Boilerplate/favicon.ico differ diff --git a/tests/Boilerplate/icon.png b/tests/Boilerplate/icon.png new file mode 100644 index 0000000..8a42581 Binary files /dev/null and b/tests/Boilerplate/icon.png differ diff --git a/tests/Boilerplate/img/.gitignore b/tests/Boilerplate/img/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Boilerplate/index.html b/tests/Boilerplate/index.html new file mode 100644 index 0000000..1623d3a --- /dev/null +++ b/tests/Boilerplate/index.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + +

Hello world! This is HTML5 Boilerplate.

+ + + + + + + + + + + diff --git a/tests/Boilerplate/js/main.js b/tests/Boilerplate/js/main.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/Boilerplate/js/plugins.js b/tests/Boilerplate/js/plugins.js new file mode 100644 index 0000000..f887480 --- /dev/null +++ b/tests/Boilerplate/js/plugins.js @@ -0,0 +1,24 @@ +// Avoid `console` errors in browsers that lack a console. +(function() { + var method; + var noop = function () {}; + var methods = [ + 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', + 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', + 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', + 'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn' + ]; + var length = methods.length; + var console = (window.console = window.console || {}); + + while (length--) { + method = methods[length]; + + // Only stub undefined methods. + if (!console[method]) { + console[method] = noop; + } + } +}()); + +// Place any jQuery/helper plugins in here. diff --git a/tests/Boilerplate/tile-wide.png b/tests/Boilerplate/tile-wide.png new file mode 100644 index 0000000..ccd739c Binary files /dev/null and b/tests/Boilerplate/tile-wide.png differ diff --git a/tests/Boilerplate/tile.png b/tests/Boilerplate/tile.png new file mode 100644 index 0000000..f820f61 Binary files /dev/null and b/tests/Boilerplate/tile.png differ diff --git a/tests/Middleware/CollapseWhitespaceTest.php b/tests/Middleware/CollapseWhitespaceTest.php new file mode 100644 index 0000000..b61f10a --- /dev/null +++ b/tests/Middleware/CollapseWhitespaceTest.php @@ -0,0 +1,22 @@ +middleware = new CollapseWhitespace(); + } + + public function testApply() + { + $compress = '

Hello world! This is HTML5 Boilerplate.

'; + $this->assertSame($compress, $this->middleware->apply( $this->html )); + } +} \ No newline at end of file diff --git a/tests/Middleware/RemoveCommentsTest.php b/tests/Middleware/RemoveCommentsTest.php new file mode 100644 index 0000000..a80dc3b --- /dev/null +++ b/tests/Middleware/RemoveCommentsTest.php @@ -0,0 +1,22 @@ +middleware = new RemoveComments(); + } + + public function testApply() + { + $this->assertNotContains("", + $this->middleware->apply( $this->html )); + } +} \ No newline at end of file diff --git a/tests/Middleware/TrimUrlsTest.php b/tests/Middleware/TrimUrlsTest.php new file mode 100644 index 0000000..713aeb0 --- /dev/null +++ b/tests/Middleware/TrimUrlsTest.php @@ -0,0 +1,25 @@ +middleware = new TrimUrls(); + } + + public function testApply() + { + $html = $this->middleware->apply($this->html); + + $this->assertNotContains("https://", $html); + $this->assertNotContains("http://", $html); + $this->assertContains("//code.jquery.com/jquery-3.2.1.min.js", $html); + } +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index e69de29..805c149 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -0,0 +1,30 @@ +getMiddleware(); + + $this->html = $this->getBoilerplateHTML(); + } + + private function getBoilerplateHTML() + { + return file_get_contents(__DIR__ .'/Boilerplate/index.html'); + } + + protected function getPackageProviders($app) + { + return [ServiceProvider::class]; + } +} \ No newline at end of file