0
のExpress.JSでExpressがUTF8文字を読み取ると、Expressはこの要求パス-/wiąz.txt
を/wiÄz.txt
と読み込み、/wiÄz.txt doesn't exist
となりますが、wiąz.txt
が存在します。リクエストパスにutf8文字を読み込むことは可能ですか?ノード
var express = require('express');
var fs = require('fs');
var app = express();
app.set('etag', false);
app.set('x-powered-by', false);
app.route('*').all(function(req, res) {
res.set('Content-Type', 'text/plain');
try {
var file = fs.readFileSync('.' + req.path, 'utf8'); // req.path starts always with /, the result is ./FILE
res.send(file);
} catch (e) {
res.send(req.path + " doesn't exist");
}
});
app.listen(80, function() {
console.log('HTTP Server is now running on port 80');
});
あなたのコードを問題に投稿できますか? –
完了。それをもう一度見てください。 –
'fs.readFileSync( '+' decodeURIComponent(req.path)+ '。txt'、 'utf8')' –