Pudu programming language
Menu
API reference

Std.Site.fileFor

1 declaration

fn

fileFor: Str -> Str -> Result[Str, Str]

The file a path is written to, relative to the pages directory, given the content type its response carries.

A page — an HTML response — is written as a directory's index.html, which every static host serves for the directory: / is index.html, and /docs, /docs/, and /module/Std.Json are each a directory with an index.html in it — /module/Std.Html included, since a page's name is its own. /404 is 404.html, the name hosts serve for a miss. Any other response — /robots.txt, /sitemap.xml, /logo.png — is written at exactly its path. Asking the response rather than the name is what keeps a page called Std.Json from becoming a file with no extension a host understands. With no content type, a last segment ending in one of FILE_EXTENSIONS is taken to be a file.

A path that could leave the output directory is refused rather than cleaned: .. and . segments, empty segments, backslashes, and control characters, as well as ? and #, which name something other than a file. A name escaped for a URL is written escaped, since that is how the host will ask for it.

Back to Std.SiteSearch related declarations