support for h-selector (HTTP URLs)

master
KatolaZ 6 years ago
parent c6cdec9c57
commit f8214c618f
  1. 22
      gosher

@ -146,6 +146,24 @@ serve_index(){
exit 0 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:-"./"} GOPHERDIR=${1:-"./"}
@ -160,6 +178,10 @@ selector=$(echo $selector | sed -r 's:\$.*::g;s:\r::g' )
} }
case $selector in case $selector in
/URL:*)
url=$(echo $selector | cut -d ":" -f 2-)
serve_redirect $url
;;
/?*|"") /?*|"")
RP1=$(realpath "${GOPHERDIR}"/"${selector}" || "") RP1=$(realpath "${GOPHERDIR}"/"${selector}" || "")
[ $? -eq 0 ] || invalid_selector "$selector" [ $? -eq 0 ] || invalid_selector "$selector"

Loading…
Cancel
Save