From 02d4f062542e7632ba116ffeed8536e90892a619 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 19 Jan 2022 17:40:21 -0500 Subject: urlrelative() fix warning when supplied with no argument --- gmi.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gmi.pl b/gmi.pl index 9a58b46..5be6e00 100755 --- a/gmi.pl +++ b/gmi.pl @@ -10,7 +10,7 @@ use bytes; use feature qw(refaliasing); no warnings qw(experimental::refaliasing); -our $VERSION = 'v0.0.20'; +our $VERSION = 'v0.0.21'; # TODO: # back() only works once; should fix this @@ -39,8 +39,8 @@ my @history; my $prompt = ""; my %commands = ( - 'url' => [sub { url($_[0],0) }, 'Go to the specified URL.'], - 'u' => [sub { url($_[0],0) }, 'Alias of `url\''], + 'url' => [sub { url($_[0]) }, 'Go to the specified URL.'], + 'u' => [sub { url($_[0]) }, 'Alias of `url\''], 'urlrelative' => [sub { urlrelative($_[0]) }, "Navigate the current URL relatively.\n\n" ."Note: if the current path is '/blog/my-post1.gmi' and 'my-post2.gmi'\n" . @@ -209,7 +209,8 @@ sub url { sub urlrelative { my ($urlr) = @_; - if (!$current_url) {print "Relative movement impossible: no current URL.\n"; return 1;} + if (! $urlr) { $urlr = ""} + if (! $current_url) {print "Relative movement impossible: no current URL.\n"; return 1;} my $end_with_slash = 1 if ($urlr =~ m|/$|); my $dot_only = 1 if ($urlr =~ m|^\.$|); my $dot_2_only = 1 if ($urlr =~ m|^\.\.$|); # since we are going up into a dir -- cgit v1.2.3