Fix the example code for correct and incorrect error handling in the documentation.
This commit is contained in:
parent
420f135b22
commit
923e7eebcb
1 changed files with 3 additions and 3 deletions
|
@ -1436,7 +1436,7 @@ if(href == "/page.svr") {
|
|||
var id = uobject.query.id;
|
||||
if(!id) id = "index";
|
||||
if(fs.existsSync("pages/" + id + ".html")) {
|
||||
fs.readFile("pages/" + id + ".html", function(err2, data2)) {
|
||||
fs.readFile("pages/" + id + ".html", function(err2, data2) {
|
||||
if(err2) throw err2; //EVIL TWO!!!
|
||||
res.writeHead(200,"OK", headers);
|
||||
res.end(data.toString().replace("{websiteContents}",data2.toString()));
|
||||
|
@ -1477,9 +1477,9 @@ if(href == "/page.svr") {
|
|||
}
|
||||
var id = uobject.query.id;
|
||||
if(!id) id = "index";
|
||||
id = id.replace(/\\/g,"/").replace(/(?:\/|^)\.\.(?=(\/|$))/g,"$1").replace(/\/+/g,"/") //Poor mans path sanitiation
|
||||
id = id.replace(/\\/g,"/").replace(/(?:\/|^)\.\.(?=(\/|$))/g,"$1").replace(/\/+/g,"/"); //Poor mans path sanitiation
|
||||
if(fs.existsSync("pages/" + id + ".html")) {
|
||||
fs.readFile("pages/" + id + ".html", function(err2, data2)) {
|
||||
fs.readFile("pages/" + id + ".html", function(err2, data2) {
|
||||
if(err2) {
|
||||
callServerError(500,err2);
|
||||
return;
|
||||
|
|
Reference in a new issue