node.js - Getting filetype in an Express route -


i have express route /doc/:id serves html representation of document, , want serve epub representation when appended ".epub". express doesn't separate on period, however, if use /doc/:id.epub sets req.params.id "id.epub". there way have file extension recognised separate parameter or need use regex extract it?

i have looked @ res.format, seems effective when accepted header set, not if url typed browser, far can see.

this works:

app.get('/doc/:filename.:ext', function(req, res) {   ... }); 

this requires part following /doc/ contains @ least 1 period, may or may not issue.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -