function resolveInRoot(root) {
    var input, result;

    input = _.chain(arguments)
        .toArray()
        .slice(1)
        .reduce(function(current, p) {
            // Handle path relative to book root ("/README.md")
            if (p[0] == '/' || p[0] == '\\') return p.slice(1);

            return current? path.join(current, p) : path.normalize(p);
        }, '')
        .value();

    result = path.resolve(root, input);

    if (!isInRoot(root, result)) {
        throw new error.FileOutOfScopeError({
            filename: result,
            root: root
        });
    }

    return result;
}
// Throw error if file is outside this folder
Throw error if file is outside this folder
Throw error if file is outside this folder
function resolveInRoot(root) {
    var input, result;
    input = _.chain(arguments)
        .toArray()
        .slice(1)
        .reduce(function(current, p) {
            if (p[0] == '/' || p[0] == '\\') return p.slice(1);
            return current? path.join(current, p) : path.normalize(p);
        }, '')
        .value();
    result = path.resolve(root, input);
    if (!isInRoot(root, result)) {
        throw new error.FileOutOfScopeError({
            filename: result,
            root: root
        });
    }
    return result;
}
function resolveInRoot ( root ) { var input , result ; input = _ . chain ( arguments ) . toArray ( ) . slice ( 1 ) . reduce ( function ( current , p ) { if ( p [ 0 ] == '/' || p [ 0 ] == '\\' ) return p . slice ( 1 ) ; return current ? path . join ( current , p ) : path . normalize ( p ) ; } , '' ) . value ( ) ; result = path . resolve ( root , input ) ; if ( ! isInRoot ( root , result ) ) { throw new error . FileOutOfScopeError ( { filename : result , root : root } ) ; } return result ; }
Throw error if file is outside this folder
Throw error if file is outside this folder
// Handle path relative to book root ("/README.md")