Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folders are not considered to exist if path contains a trailing '/' #13

Closed
eugirdor opened this issue Jun 11, 2015 · 3 comments
Closed

Comments

@eugirdor
Copy link
Contributor

Under the posix implementation (haven't tested Windows), any methods that work with directories do not work if the path contains a trailing '/'.

Given the two tests:

Passes /var/www:

it 'should return true when directory exists (w/o trailing /)', (done) ->
    fs.writeFileSync('/var/www/index.php', '')
        fs.exists('/var/www', (exists) ->
            expect(exists).to.be.true
            done()
        )

Fails /var/www/:

it 'should return true when directory exists (w/trailing /)', (done) ->
    fs.writeFileSync('/var/www/index.php', '')
    fs.exists('/var/www/', (exists) ->
        expect(exists).to.be.true
        done()
    )
@davidkudera
Copy link
Member

Hello and thanks, do you want to create a pull request?

@eugirdor
Copy link
Contributor Author

I don't have a fix for the issue currently. Somewhere in the code it needs to check if the path sans the trailing '/' exists and that it is a directory. If it is not a directory (i.e. /var/ww/index.php/) it needs to throw an ENOTDIR error, which does not happen either right now, you always get ENOENT instead.

I think the fix might need to be in two places, the way the code is structured right now. existsSync to fix the test I posted, but also in realpathSync to throw the appropriate error.

What do you think?

@eugirdor
Copy link
Contributor Author

Those should probably be two separate pull requests. The issue with the wrong error being thrown is kind of moot until #12 gets fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants