swiftgemini

[ACTIVE] gemini protocol in swift
git clone git://git.figbert.com/swiftgemini.git
Log | Files | Refs | README

commit aec8d755c2b3e5b2a8fd7d719dd005617058e8a6
parent 6680ed18569dfeff55a38bc168b1d4f0295ed216
Author: FIGBERT <figbert@figbert.com>
Date:   Sun, 24 Jul 2022 19:32:35 -0700

Add non-gemini text variable

Diffstat:
MSources/SwiftGemini/SwiftGemini.swift | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Sources/SwiftGemini/SwiftGemini.swift b/Sources/SwiftGemini/SwiftGemini.swift @@ -10,6 +10,7 @@ class GeminiRequest { var status: StatusCode? var meta: MetaHeader? var body: Data? + var text: String? var gemtext: String? init?(_ url: URL) throws { @@ -77,8 +78,11 @@ class GeminiRequest { let ix = self.response!.firstIndex(of: 13)! + 2 let body = self.response!.suffix(from: ix) - if case let .MIME(mime) = self.meta, mime.hasPrefix("text/gemini") || mime.isEmpty { - self.gemtext = String(data: body, encoding: .utf8) + if case let .MIME(mime) = self.meta, mime.hasPrefix("text/") || mime.isEmpty { + if mime.hasPrefix("text/gemini") || mime.isEmpty { + self.gemtext = String(data: body, encoding: .utf8) + } + self.text = String(data: body, encoding: .utf8) } else { self.body = body }