From 474cedbf4993c2665fcda47b32c8a2192afbed9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Thu, 23 Jun 2022 01:37:34 +0200
Subject: [PATCH] Bugfix

---
 VERSION                             | 2 +-
 lib/PZ/Controller/Shortcut.pm       | 2 +-
 lib/PZ/Schema/ResultSet/Shortcut.pm | 5 ++++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/VERSION b/VERSION
index 0c62199..ee1372d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.1
+0.2.2
diff --git a/lib/PZ/Controller/Shortcut.pm b/lib/PZ/Controller/Shortcut.pm
index 48d1746..e7a9e30 100644
--- a/lib/PZ/Controller/Shortcut.pm
+++ b/lib/PZ/Controller/Shortcut.pm
@@ -43,7 +43,7 @@ sub create ($c) {
 
     $shortcut ||= $c->schema->resultset('Shortcut')->create({
         %data,
-        shortcut => ($custom || $c->schema->resultset('Shortcut')->generate()),
+        shortcut => $c->schema->resultset('Shortcut')->generate($custom),
     });
 
     $url = 'https://' . $c->config->{domain} . '/' . $shortcut->shortcut;
diff --git a/lib/PZ/Schema/ResultSet/Shortcut.pm b/lib/PZ/Schema/ResultSet/Shortcut.pm
index 88ae4f0..b19c821 100644
--- a/lib/PZ/Schema/ResultSet/Shortcut.pm
+++ b/lib/PZ/Schema/ResultSet/Shortcut.pm
@@ -10,7 +10,10 @@ use Data::Random qw(rand_chars);
 use constant SIZE => 4;
 
 sub generate {
-    my $class = shift;
+    my $class  = shift;
+    my $custom = shift;
+
+    return $custom if $custom;
 
     my $shortcut;
 
-- 
GitLab