From e52c14ee24be22451f016bd449de1caa2232e94c Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 29 Jan 2022 09:17:08 -0500 Subject: access_resource() can access uris without scheme --- gmi.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gmi.pl b/gmi.pl index 8487d6e..8a72f54 100755 --- a/gmi.pl +++ b/gmi.pl @@ -33,8 +33,8 @@ use File::Slurper qw(read_dir); # CPAN # sudo cpanm IO::Socket::SSL URL::XS IO::Pager Text::Wraper Term::ReadKey Path::Naive Text::ParseWords Term::ReadLine Smart::Comments URI::Encode IO::Socket::SSL::Utils File::Slurper my $wrapper = Text::Wrapper->new(columns=>70, body_start=>''); -#$ENV{PAGER} = 'most'; -$ENV{PAGER} = 'less -R'; +$ENV{PAGER} = 'most'; +#$ENV{PAGER} = 'less -r'; my $use_pager = 1; my $pager_text_wrap_auto = 1; my $doc_out = 1; # display doc for human consumption? @@ -435,6 +435,9 @@ sub urlrelative { $c_p_url->{path} .= "/"; # normalize path will remove it } substr($c_p_url->{path},0,1,''); + if ($c_p_url->{path} eq '/') { + delete $c_p_url->{path}; # dont want to ask for 'gemini://host.com//' + } url(return_url($c_p_url)); return 0; } @@ -461,6 +464,9 @@ sub urlrelative { $c_p_url->{path} .= "/"; # normalize path will remove it } substr($c_p_url->{path},0,1,''); + if ($c_p_url->{path} eq '/') { + delete $c_p_url->{path}; # dont want to ask for 'gemini://host.com//' + } ### $c_p_url url(return_url($c_p_url)); return 0; @@ -584,8 +590,7 @@ sub nav { $link = $history[$n][0]; } else { - my $m = $n+1; - print $OUT "'$m' isn't available.\n"; + print $OUT "'" . ($n+1) ."' isn't available.\n"; return 1; } access_resource($link); @@ -596,6 +601,8 @@ sub access_resource { # This implies it is valid fqdn if (has_scheme($link)) { url("$link"); + } elsif (substr($link,0,2) eq '//') { # technically valid + url("gemini:$link"); } else { my $c_url = parse_url($current_url); @@ -606,9 +613,9 @@ sub access_resource { if ($begin_with_slash) { delete($c_url->{path}); $c_url->{path} = $link; - if ($end_with_slash){ - $c_url->{path} .= "/"; - } + #if ($end_with_slash){ + # $c_url->{path} .= "/"; + #} substr($c_url->{path},0,1,''); url(return_url($c_url)); return 0; -- cgit v1.2.3