about summary refs log tree commit diff stats
path: root/adapter
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-12 19:42:04 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-12 19:42:04 +0100
commit820f0f0f039252533133c3bd1037a73036815a45 (patch)
tree305dd3cd0416123c27701c199164fa54e822a7fb /adapter
parent5efdc54db2d2c766d7ce7c6545207ce2ce805620 (diff)
downloadchawan-820f0f0f039252533133c3bd1037a73036815a45.tar.gz
twtstr: import functions from gopher2html
Diffstat (limited to 'adapter')
-rw-r--r--adapter/gopher/gopher2html.nim19
1 files changed, 2 insertions, 17 deletions
diff --git a/adapter/gopher/gopher2html.nim b/adapter/gopher/gopher2html.nim
index 4821814f..cfdeab1e 100644
--- a/adapter/gopher/gopher2html.nim
+++ b/adapter/gopher/gopher2html.nim
@@ -5,6 +5,8 @@ import std/os
 import std/streams
 import std/strutils
 
+import utils/twtstr
+
 type GopherType = enum
   UNKNOWN = "unsupported"
   TEXT_FILE = "text file"
@@ -38,23 +40,6 @@ func gopherType(c: char): GopherType =
   of 'p': PNG
   else: UNKNOWN
 
-func htmlEscape(s: string): string =
-  result = ""
-  for c in s:
-    case c
-    of '<': result &= "&lt;"
-    of '>': result &= "&gt;"
-    of '&': result &= "&amp;"
-    of '"': result &= "&quot;"
-    of '\'': result &= "&apos;"
-    else: result &= c
-
-func until(s: string, c: char, starti = 0): string =
-  for i in starti ..< s.len:
-    if s[i] == c:
-      break
-    result &= s[i]
-
 const ControlPercentEncodeSet = {char(0x00)..char(0x1F), char(0x7F)..char(0xFF)}
 const QueryPercentEncodeSet = (ControlPercentEncodeSet + {' ', '"', '#', '<', '>'})
 const PathPercentEncodeSet = (QueryPercentEncodeSet + {'?', '`', '{', '}'})