solidusjs / solidus

A simple server that generates pages from JSON and Templates
MIT License
28 stars 7 forks source link

Typos in redirect config are fatal / bad messaging #59

Open pushred opened 11 years ago

pushred commented 11 years ago

A bad key in the redirect JSON config causes the server to fail in certain environments. Dev seemed to work but deploying to modulus didn't work. Thankfully in the latter I was given better feedback in the log about what was wrong.

https://github.com/SparkartGroupInc/keithurban.net/commit/1ee1fe0ebda4a8d83384b962b973fcc7537d3762

Fatal error: Cannot call method 'charAt' of undefined

vs.

path.js:336
    var isAbsolute = path.charAt(0) === '/',
                          ^
TypeError: Cannot call method 'charAt' of undefined
    at Object.exports.normalize (path.js:336:27)
    at new Redirect (/mnt/data/1/node_modules/solidus/lib/redirect.js:21:33)
    at /mnt/data/1/node_modules/solidus/lib/server.js:142:20
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)
Fauntleroy commented 11 years ago

I'm not sure exactly what you want me to do about this. Do you want to check all the keys in the redirect JSON and see if they're on the whitelist? I suppose we could put pre-emptive error checking like that into Solidus, but we'd end up having lots of code in place to respond to weird user input.