summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-07-21 23:45:49 +0100
committerKatolaZ <katolaz@freaknet.org>2018-07-21 23:45:49 +0100
commitf8214c618faf6f99eebabd1b6d47a538eb938ab0 (patch)
treecefe6e89c1d0eba7f78cc9f05ddb9676f06f46b2
parentc6cdec9c576439cea1a625947d1fa24270c06ebb (diff)
support for h-selector (HTTP URLs)
-rwxr-xr-xgosher22
1 files changed, 22 insertions, 0 deletions
diff --git a/gosher b/gosher
index 8203bf6..a0fa98b 100755
--- a/gosher
+++ b/gosher
@@ -146,6 +146,24 @@ serve_index(){
exit 0
}
+### Serve an HTML URL through a redirect page
+## function
+serve_redirect(){
+ url=$1
+ cat<< EOF
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>gopher redirect</title>
+ </head>
+ <body>
+ Click to be redirected to: <a href="$url">$url</a>
+ </body>
+EOF
+
+}
+
+
GOPHERDIR=${1:-"./"}
@@ -160,6 +178,10 @@ selector=$(echo $selector | sed -r 's:\$.*::g;s:\r::g' )
}
case $selector in
+ /URL:*)
+ url=$(echo $selector | cut -d ":" -f 2-)
+ serve_redirect $url
+ ;;
/?*|"")
RP1=$(realpath "${GOPHERDIR}"/"${selector}" || "")
[ $? -eq 0 ] || invalid_selector "$selector"