From 0ade9914918238b8da35e995fe9782a517988ae2 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Tue, 5 May 2020 11:04:22 -0400 Subject: Fixed link handling. Can now navigate links and page up/down. --- protocol.f90 | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'protocol.f90') diff --git a/protocol.f90 b/protocol.f90 index 52b6430..130c866 100644 --- a/protocol.f90 +++ b/protocol.f90 @@ -48,7 +48,6 @@ contains if(send_string(conn%ssl, url//c_carriage_return//c_new_line, trimming=.false.)) then bytes_received = retrieve_characters(conn%ssl, buffer) - Print *, bytes_received do while(bytes_received > 0) do i=1, bytes_received @@ -115,4 +114,35 @@ contains end subroutine get_redirect_url + subroutine handle_relative_url(current_url, path) + implicit none + + character(*), intent(inout)::current_url + character(*), intent(in)::path + + integer::past_protocol, first_slash, last_slash + + past_protocol = index(current_url, "://") + if(past_protocol > 0) then + + past_protocol = past_protocol + 3 + + if(path(1:1) == "/") then + + first_slash = index(current_url(past_protocol:len_trim(current_url)), "/") + current_url = current_url(1:(past_protocol + first_slash - 1))//path + + else + + last_slash = index(current_url, "/", back=.true.) + if(last_slash > 0) then + current_url = current_url(1:last_slash)//path + end if + + end if + + end if + + end subroutine handle_relative_url + end module gemini_protocol \ No newline at end of file -- cgit v1.2.3