Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Check whether a path has hidden directory or whether a file/directory is hidden.
* 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);

This comment has been minimized.

Copy link

@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