Ensured uniqueness on imported short URLs short code

This commit is contained in:
Alejandro Celaya
2020-10-25 10:26:11 +01:00
parent 2256f6a9e7
commit b1a073b1ab
3 changed files with 74 additions and 10 deletions

View File

@@ -135,8 +135,8 @@ class ShortUrl extends AbstractEntity
*/
public function regenerateShortCode(): self
{
// In ShortUrls where a custom slug was provided, do nothing
if ($this->customSlugWasProvided) {
// In ShortUrls where a custom slug was provided, throw error, unless it is an imported one
if ($this->customSlugWasProvided && $this->importSource === null) {
throw ShortCodeCannotBeRegeneratedException::forShortUrlWithCustomSlug();
}