send
send copied to clipboard
Extend `format` option to support redirection of trailing slash for directories
trafficstars
Extended format option from ( *true | false ) to ( *'follow' | 'redirect' | false ).
'follow' behaves the same as the old true, and keep as default.
'redirect' is used for the redirection new feature.
If trailing slash for directories is absent and index is defined, when format is set to 'redirect', it redirects the page using HTTP 302 to the URL with trailing slash added, at the same time respecting previous scheme and query.
Return value of await send() is true when such a redirection happened, in contrast of undefined when encountering errors and pathname when the file is served.