aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2023-12-22 20:45:04 -0700
committerNavan Chauhan <navanchauhan@gmail.com>2023-12-22 20:45:04 -0700
commitb89c980ee13eafe0b14202e40617d4ed3c2262f7 (patch)
tree1434c07fe55728555f186dfd35196b2213565d2c
parent9fc992d316ffb2773df1a1fd352602cedadce2be (diff)
add URL: redirect to server1.1.2
-rw-r--r--Sources/swift-gopher/gopherHandler.swift8
-rw-r--r--example-gopherdata/gophermap3
2 files changed, 10 insertions, 1 deletions
diff --git a/Sources/swift-gopher/gopherHandler.swift b/Sources/swift-gopher/gopherHandler.swift
index cd150e3..0ac5c31 100644
--- a/Sources/swift-gopher/gopherHandler.swift
+++ b/Sources/swift-gopher/gopherHandler.swift
@@ -334,6 +334,14 @@ final class GopherHandler: ChannelInboundHandler {
return .string(prepareGopherMenu(path: preparePath()))
}
+ // Check if request is an HTTP url
+ if request.hasPrefix("URL:") {
+ let url = String(request.dropFirst(4))
+ return .string(
+ "<!DOCTYPE html><html><head><meta http-equiv=\"refresh\" content=\"0; url=\(url)\" /></head><body></body></html>"
+ )
+ }
+
// Again, fix for the iOS client. Might as well make my own client
if request.hasSuffix("\n") {
request = String(request.dropLast())
diff --git a/example-gopherdata/gophermap b/example-gopherdata/gophermap
index 1047743..42358c8 100644
--- a/example-gopherdata/gophermap
+++ b/example-gopherdata/gophermap
@@ -23,4 +23,5 @@
iWelcome to your Gopherspace!
1example /example localhost 8080
0hello_world.txt /hello_world.txt localhost 8080
-1Other Gopher servers in the world (via Floodgap) /world gopher.floodgap.com 70 \ No newline at end of file
+1Other Gopher servers in the world (via Floodgap) /world gopher.floodgap.com 70
+hURL Redirect to a website URL:https://web.navan.dev/?utm_source=example_gophermap localhost 8080