summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-01-19 17:40:21 -0500
committerjake <jake@jakes-mail.top>2022-01-19 17:40:21 -0500
commit02d4f062542e7632ba116ffeed8536e90892a619 (patch)
tree32b62bdd15c62288184482398ac615809f741384
parent707dbdbba8958fb2119265cdff1d1dbe57cc5580 (diff)
urlrelative() fix warning when supplied with no argument
-rwxr-xr-xgmi.pl9
1 files 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