From 9852f8312949192f3963eaa6b4061f542a508e56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Wed, 14 Feb 2024 20:41:47 +0100
Subject: [PATCH] Podpora parametru title

---
 VERSION                       |  2 +-
 lib/PZ/Controller/Shortcut.pm | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/VERSION b/VERSION
index 834f262..dbe5900 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.8.0
+2.8.1
diff --git a/lib/PZ/Controller/Shortcut.pm b/lib/PZ/Controller/Shortcut.pm
index d992049..316fcec 100644
--- a/lib/PZ/Controller/Shortcut.pm
+++ b/lib/PZ/Controller/Shortcut.pm
@@ -54,12 +54,15 @@ sub create ($c) {
         return $c->error(400, "Zkratka $custom už je použitá") if $exists;
     }
 
-    my $title = '';
-    my $ua    = Mojo::UserAgent->new;
+    my $title = $args->{title};
 
-    eval {
-        $title = $ua->get($url)->result->dom->at('title')->text;
-    };
+    if ( ! $title ) {
+        my $ua = Mojo::UserAgent->new;
+
+        eval {
+            $title = $ua->get($url)->result->dom->at('title')->text;
+        };
+    }
 
     my $user = $c->stash->{user} // $c->current_user;
 
-- 
GitLab