From 483ef88bd1f0031e8f45b753b8c9bf07481b3df6 Mon Sep 17 00:00:00 2001 From: Frano <> Date: Mon, 23 Nov 2020 09:21:40 +0100 Subject: [PATCH] Update package to version 3.* to match Laravel framework version 8.* --- CHANGELOG.md | 11 ++++++++++ README.md | 21 ++++++++++--------- composer.json | 10 ++++----- phpunit.xml | 38 +++++++++++----------------------- src/RoutingServiceProvider.php | 2 +- src/UrlGenerator.php | 4 +++- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb3d2b2..226cf5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # CHANGELOG +## v3.0.0 (2020-11-23) + +### Added + - Added support for Laravel 8.x version + - Added support for PHP 8.0 version + + ## v2.0.2 (2020-04-01) + + ### Added + - Added support for Laravel 7.x version + ## v1.1.0 (2019-12-19) ### Fixed diff --git a/README.md b/README.md index 89689e9..9e067df 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Laravel Trailing Slash -Adds url formatting and redirection with trailing slash to Laravel 7.x, 6.x and 5.x. +Adds url formatting and redirection with trailing slash to Laravel framework versions 8.x, 7.x, 6.x and 5.x. [![Build For Laravel](https://img.shields.io/badge/Built_for-Laravel-orange.svg)](https://styleci.io/repos/79834672) [![Latest Stable Version](https://poser.pugx.org/fsasvari/laravel-trailing-slash/v/stable)](https://packagist.org/packages/fsasvari/laravel-trailing-slash) @@ -10,13 +10,14 @@ Adds url formatting and redirection with trailing slash to Laravel 7.x, 6.x and ## Compatibility Chart -| Laravel Trailing Slash | Laravel | PHP | -|-----------------------------------------------------------------------|-----------|---------| -| [2.x](https://github.com/fsasvari/laravel-trailing-slash/tree/v2.0.2) | 7.x | 7.3+ | -| [1.x](https://github.com/fsasvari/laravel-trailing-slash/tree/v1.1.0) | 6.x | 7.2+ | -| [0.3.x](https://github.com/fsasvari/laravel-trailing-slash/tree/0.3) | 5.7-5.8 | 7.1.3+ | -| [0.2.x](https://github.com/fsasvari/laravel-trailing-slash/tree/0.2) | 5.6 | 7.1.3+ | -| [0.1.x](https://github.com/fsasvari/laravel-trailing-slash/tree/0.1) | 5.5 | 7.0.0+ | +| Laravel Trailing Slash | Laravel | PHP | +|-----------------------------------------------------------------------|-----------|------------| +| [3.x](https://github.com/fsasvari/laravel-trailing-slash/tree/v3.0.0) | 8.x | 7.3+/8.0+ | +| [2.x](https://github.com/fsasvari/laravel-trailing-slash/tree/v2.0.2) | 7.x | 7.3+ | +| [1.x](https://github.com/fsasvari/laravel-trailing-slash/tree/v1.1.0) | 6.x | 7.2+ | +| [0.3.x](https://github.com/fsasvari/laravel-trailing-slash/tree/0.3) | 5.7-5.8 | 7.1.3+ | +| [0.2.x](https://github.com/fsasvari/laravel-trailing-slash/tree/0.2) | 5.6 | 7.1.3+ | +| [0.1.x](https://github.com/fsasvari/laravel-trailing-slash/tree/0.1) | 5.5 | 7.0.0+ | ## Installation @@ -31,7 +32,7 @@ composer require fsasvari/laravel-trailing-slash Or add it directly by copying next line into composer.json: ``` -"fsasvari/laravel-trailing-slash": "2.*" +"fsasvari/laravel-trailing-slash": "3.*" ``` ### Step 2: Service Provider @@ -101,7 +102,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen ## Notice -There is a problem with overriding Laravel's `Paginator` and `LengthAwarePaginator` classes. So, every time you use `paginate()` method on your models, query builders etc., you must set current path for pagination links. Example: +There is a problem with overriding Laravel `Paginator` and `LengthAwarePaginator` classes. So, every time you use `paginate()` method on your models, query builders etc., you must set current path for pagination links. Example: ```php $texts = Text::where('is_active', 1)->paginate(); diff --git a/composer.json b/composer.json index 08128c8..32a262b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fsasvari/laravel-trailing-slash", - "description": "Adds redirection with trailing slash in Laravel.", + "description": "The package that adds redirection with trailing slash to Laravel framework.", "keywords": ["redirect", "laravel", "php"], "license": "MIT", "homepage": "https://github.com/fsasvari/laravel-trailing-slash", @@ -11,12 +11,12 @@ } ], "require": { - "php": "^7.3", - "illuminate/routing": "7.*" + "php": "^7.3|^8.0", + "illuminate/routing": "8.*" }, "require-dev": { - "mockery/mockery": "^1.3.1", - "phpunit/phpunit": "^9.0" + "mockery/mockery": "^1.4.2", + "phpunit/phpunit": "^9.4.3" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 585cc82..1dc95e8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,27 +1,13 @@ - - - - ./tests - - - - - ./src - - ./src/ - - - - \ No newline at end of file + + + + ./src + + + + + ./tests + + + diff --git a/src/RoutingServiceProvider.php b/src/RoutingServiceProvider.php index 921c40e..b4bc235 100644 --- a/src/RoutingServiceProvider.php +++ b/src/RoutingServiceProvider.php @@ -44,7 +44,7 @@ protected function registerUrlGenerator() // get the information it needs to function. This just provides some of // the convenience features to this URL generator like "signed" URLs. $url->setSessionResolver(function () use ($app) { - return $app['session']; + return $app['session'] ?? null; }); $url->setKeyResolver(function () use ($app) { diff --git a/src/UrlGenerator.php b/src/UrlGenerator.php index 8b7de47..6dabc94 100644 --- a/src/UrlGenerator.php +++ b/src/UrlGenerator.php @@ -18,6 +18,8 @@ class UrlGenerator extends BaseUrlGenerator */ public function format($root, $path, $route = null) { - return parent::format($root, $path, $route).(Str::contains($path, '#') ? '' : '/'); + $trailingSlash = (Str::contains($path, '#') ? '' : '/'); + + return rtrim(parent::format($root, $path, $route), '/').$trailingSlash; } }