Last active
December 30, 2015 08:39
-
-
Save shamasis/7804182 to your computer and use it in GitHub Desktop.
Function to test whether a path has any hidden folder in it or whether a file is hidden or not using regular expressions and not using the file-system. I find it particularly useful to validate a path that is user-provided and does not actually exist on disk. For unix based systems only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Tests whether a path is a directory or possibly a file reference. | |
| * | |
| * @param {string} path | |
| * @returns {boolean} | |
| */ | |
| isUnixDirectory: function (path) { | |
| return (/(^\.+$)|(\/$)/).test(path); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment