md render bug fixed

This commit is contained in:
dachus 2023-02-16 12:22:19 -06:00
parent d821feec79
commit e882d40579

View File

@ -3,17 +3,23 @@
^- simple-payload:http
=/ turl=tape (trip url.request)
=/ turl-len (lent turl)
=/ scry-path=@t
:: TODO all the text parsing here is super ugly, might
:: be a better way to do it, but basically just detect
:: .md or .html, manipulate the scry-path, add
:: proper headers, and that's it.
=/ [content-type=@t scry-path=@t]
=+ md=(find ".md" turl)
?: &(?=(^ md) =((add u.md 3) turl-len))
:- 'text/plain; charset=utf-8'
(crip (weld "/md" (swag [0 (sub turl-len 3)] turl)))
:- 'text/html; charset=utf-8'
=+ html=(find ".html" turl)
?: &(?=(^ html) =((add u.html 5) turl-len))
(crip (weld "/html" (swag [0 (sub turl-len 5)] turl)))
(crip (weld "/html" turl))
::
^- [response-header:http (unit octs)]
:- [200 ['Content-Type' 'text/html; charset=utf-8']~]
:- [200 ['Content-Type' content-type]~]
%- some
%- as-octs:mimes:html
.^ @t %gx