diff --git a/CHANGELOG.md b/CHANGELOG.md index 18679c8..2a58018 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ # Changelog +**2.2.0 (released 2020-02-27):** +- Added a default option to enforce HTTPS on destination URLs as a config option. [#36](https://github.com/ash-jc-allen/short-url/pull/36) + **2.1.0 (released 2020-02-19):** - Added the key salt (used for generating random URL keys) as a config option. [#32](https://github.com/ash-jc-allen/short-url/pull/32) - **2.0.0 (released 2020-02-14):** - Added the functionality to track a visitor's referer URL. - Added the functionality to track a user's device type. diff --git a/README.md b/README.md index c8526bf..b3c6754 100644 --- a/README.md +++ b/README.md @@ -491,6 +491,7 @@ Note: A contribution guide will be added soon. - [Ash Allen](https://ashallendesign.co.uk) - [Jess Pickup](https://jesspickup.co.uk) (Logo) - [Nathan Giesbrecht](https://github.com/NathanGiesbrecht) +- [Carlos A. Escobar](https://github.com/carlosjs23) - [All Contributors](https://github.com/ash-jc-allen/short-url/graphs/contributors) ## Changelog @@ -501,7 +502,6 @@ Check the [CHANGELOG](CHANGELOG.md) to get more information about the latest cha Check the [UPGRADE](UPGRADE.md) guide to get more information on how to update this library to newer versions. - ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/config/short-url.php b/config/short-url.php index 602b047..2b8460d 100644 --- a/config/short-url.php +++ b/config/short-url.php @@ -11,7 +11,7 @@ | from using the default route that comes with this library. | This allows you to define your own route that points to | the controller at: - + | | AshAllenDesign\ShortURL\Controllers\ShortURLController | */ @@ -22,13 +22,13 @@ | Enforce HTTPS in the destination URL |-------------------------------------------------------------------------- | - | Here you may specify if the visitor is redirected to the HTTPS version - | of the destination URL. This can be particularly useful if you're allowing - | your web app users to create their own shortened URLS and you don't want to - | use the secure() method in every occasion. + | Here you may specify if the visitor is redirected to the HTTPS + | version of the destination URL by default. This option can be + | overridden when creating the short URL with the ->secure() + | method. | */ - 'enforce_https' => true, + 'enforce_https' => true, /* |-------------------------------------------------------------------------- diff --git a/src/Classes/Validation.php b/src/Classes/Validation.php index 3186f41..21e8633 100644 --- a/src/Classes/Validation.php +++ b/src/Classes/Validation.php @@ -107,8 +107,7 @@ protected function validateDefaultRouteOption(): bool } /** - * Validate that the enforce_https option - * is a boolean. + * Validate that the enforce_https option is a boolean. * * @return bool * @throws ValidationException diff --git a/tests/Unit/Classes/BuilderTest.php b/tests/Unit/Classes/BuilderTest.php index 2312ee0..c410ec1 100644 --- a/tests/Unit/Classes/BuilderTest.php +++ b/tests/Unit/Classes/BuilderTest.php @@ -80,6 +80,15 @@ public function destination_url_is_not_changed_to_https_if_enforce_https_flag_is $this->assertEquals('http://domain.com', $shortUrl->destination_url); } + /** @test */ + public function destination_url_is_changed_to_https_if_enforce_https_flag_is_set_to_false_in_the_config_but_set_when_creating_url() + { + Config::set('short-url.enforce_https', false); + $builder = new Builder(); + $shortUrl = $builder->destinationUrl('http://domain.com')->secure()->make(); + $this->assertEquals('https://domain.com', $shortUrl->destination_url); + } + /** @test */ public function track_visits_flag_is_set_from_the_config_if_it_is_not_explicitly_set() {