Skip to content

Commit

Permalink
Merge pull request #124 from ash-jc-allen/release/v7.0.0
Browse files Browse the repository at this point in the history
Release - v7.0.0
  • Loading branch information
ash-jc-allen authored Apr 4, 2022
2 parents 49c1e22 + 5c756f0 commit 53df9e3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

**v7.0.0 (released 2022-04-04):**
- Added ability to remove the prefix from default short URLs. [#123](https://github.com/ash-jc-allen/short-url/pull/123)
- Added ability to define middleware for the default short URL route. [#121](https://github.com/ash-jc-allen/short-url/pull/121)
- Added ability to set the key generator on-the-fly. [#122](https://github.com/ash-jc-allen/short-url/pull/122)

**v6.3.0 (released 2022-01-24):**
- Added support for Laravel 9. [#116](https://github.com/ash-jc-allen/short-url/pull/116)

Expand Down
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ $builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('http://destination.com')->redirectStatusCode(302)->make();
```

### Activation and Deactivation Times
#### Activation and Deactivation Times

By default, all short URLs that you create are active until you delete them. However, you may set activation and deactivation
times for your URLs when you're creating them.
Expand Down Expand Up @@ -378,6 +378,8 @@ do this are provided for this in the [Customisation](#customisation) section bel

#### Customising the Default Route

##### Customising the Prefix

The package comes with a route that you can use for your short URLs. By default, this route is `/short/{shortURLKey}`.

You might want to keep using this default route but change the `/short/` prefix to something else. To do this, you can change the `prefix` field in the config.
Expand All @@ -388,6 +390,36 @@ For example, to change the default short URL to `/s`, you could change the confi
'prefix' => 's',
```

##### Removing the Prefix

You may also remove the prefix from the default route completely. For example, if you want your short URL to be accessible via `/{shortUrlKey}`, then you can update the `prefix` config value to `null` like so:

```
'prefix' => null,
```

##### Defining Middleware

You may wish to run the default short URL through some middleware in your application. To do this, you can define the middleware that the route should use via the `middleware` config value.

For example, if you have a `MyAwesomeMiddleware` class, you could update your `short-url` config like so:

```
'middleware' => [
MyAwesomeMiddleware::class,
],
```

You can also use this same approach to define middleware groups rather than individual middleware classes. For example, if you want your default short URL route to use the `web` middleware group, you could update your config like so:

```
'middleware' => [
'web',
],
```

It's important to note that this middleware will only be automatically applied to the default short URL route that ships with the package. If you are defining your own route, you'll need to apply this middleware to your route yourself.

#### Disabling the Default Route
If you have added your own custom route to your project, you may want to block the default route that the package provides.
You can do this by setting the following value in the config:
Expand Down
21 changes: 21 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
# Upgrade Guide

## Contents
- [Upgrading from 6.* to 7.0.0](#upgrading-from-6-to-700)
- [Upgrading from 5.* to 6.0.0](#upgrading-from-5-to-600)
- [Upgrading from 4.* to 5.0.0](#upgrading-from-4-to-500)
- [Upgrading from 3.* to 4.0.0](#upgrading-from-3-to-400)
- [Upgrading from 2.* to 3.0.0](#upgrading-from-2-to-300)
- [Upgrading from 1.* to 2.0.0](#upgrading-from-1-to-200)

## Upgrading from 6.* to 7.0.0

### Method Signature Update

As of Short URL v7.0.0, one of the method's signatures have been updated in order to allow the default short URL prefix to be nullable.

The signature of the `prefix()` method in the `AshAllenDesign\ShortURL\Classes\Builder` class has changed from:

```
public function prefix(): string
```

to:

```
public function prefix(): ?string
```

Although it's unlikely that you are overriding this method, if you are, you'll need to update the method signature to the new format.

## Upgrading from 5.* to 6.0.0

### Laravel - Minimum Required Version
Expand Down
5 changes: 2 additions & 3 deletions config/short-url.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
| Middleware
|--------------------------------------------------------------------------
|
| This configuration value is used to add middleware to the route. Empty
| middleware will be used if none is set
| Define any middleware that the default short URL route will use.
|
*/
'middleware' => [

//
],

/*
Expand Down

0 comments on commit 53df9e3

Please sign in to comment.