Skip to content

Commit

Permalink
Merge pull request #237 from liam-fitzgerald/lf/fix-url-encdoe
Browse files Browse the repository at this point in the history
docket: fix URL encoding handling
  • Loading branch information
arthyn authored Nov 21, 2023
2 parents 4b4384e + 46cc5eb commit 3c09610
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions desk/app/docket.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -656,28 +656,37 @@
?~ file [glob 'file without filename' err]
?~ type [glob (cat 3 'file without type: ' u.file) err]
?^ code [glob (cat 3 'strange encoding: ' u.code) err]
=/ filp (rush u.file fip)
?~ filp [glob (cat 3 'strange filename: ' u.file) err]
=/ filp (fip u.file)
:: ignore metadata files and other "junk"
::TODO consider expanding coverage
::
?: =('.DS_Store' (rear `path`u.filp))
?: =('.DS_Store' (rear `path`filp))
[glob err]
:: make sure to exclude the top-level dir from the path
::
:_ err
%+ ~(put by glob) (slag 1 `path`u.filp)
%+ ~(put by glob) (slag 1 `path`filp)
[u.type (as-octs:mimes:html body)]
::
++ split-at
=| fst=tape
|= [=tape char=@tD]
^+ [fst fst]
?~ tape [fst tape]
?: =(i.tape char)
[fst t.tape]
$(tape t.tape, fst (snoc fst i.tape))
::
++ fip
=, de-purl:html
;: cook
|=(pork (weld q (drop p)))
deft
|=(a=cord (rash a (more fas smeg)))
crip
(star ;~(pose (cold '%20' (just ' ')) next))
==
|= fil=@t
=/ [fil=tape ext=tape] (split-at (trip fil) '.')
=- (snoc - (crip ext))
%+ turn
(scan fil (most fas (star ;~(less fas next))))
|= t=^tape
%- crip
(en-urlt:html t)
::
::
++ inline-js-response
|= js=cord
Expand All @@ -703,6 +712,7 @@
?: =(suffix /desk/js)
%- inline-js-response
(rap 3 'window.desk = "' u.des '";' ~)
=. suffix (turn suffix |=(s=@t (crip (en-urlt:html (trip s)))))
=/ requested
?: (~(has by glob) suffix) suffix
/index/html
Expand Down

0 comments on commit 3c09610

Please sign in to comment.