operasoftware/robohydra — pull request #4 by iAdramelk (2012-08-15 15:00:44+00:00)
Title: Fix for a bug in RoboHydraHead.prototype.canHandle

There is a bug in **RoboHydraHead.prototype.canHandle**. The problem is with the following place in code:

return reqPath.length === headPath.length || reqPath[headPath.length] === '/';

If headPath value is exact string everything is working. But if headPath is RegEx it breaks. Example:

exports.getBodyParts = function(conf) {
return {
heads: [
new RoboHydraHeadFilesystem({
mountPath: "\\$guic/blocks_newgui",
documentRoot: 'blocks_newgui'
})
]
};
};

Because there is a '$' symbol in the path I have to escape it with '\\'. As a result **headPath.length** became 2 symbols longer than **reqPath.length**, so following expression returns false:

reqPath.length === headPath.length || reqPath[headPath.length] === '/'

and server returns 404 Not Found.

I tried to fix this problem in my branch and it looks like it's working, but I'm not entirely sure that my codestyle match yours. But I hope it will still help you to this this problem.