Create a gist now

Instantly share code, notes, and snippets.

Check whether a path has hidden directory or whether a file/directory is hidden.http://stackoverflow.com/questions/8905680/nodejs-check-for-hidden-files/
/**
* Checks whether a path starts with or contains a hidden file or a folder.
*
* @param {string} source - The path of the file that needs to be validated.
* returns {boolean} - `true` if the source is blacklisted and otherwise `false`.
*/
var isUnixHiddenPath = function (path) {
return (/(\/|^)\.[^\/\.]/g).test(path);
};
@iahu
iahu commented Sep 14, 2015

test this case:
isUnixHiddenPath('../test'); // true
isUnixHiddenPath('./'); // true

It better change to
return (/(\/|^|.)\.[^\/\.]/g).test(path);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment