镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

path.isAbsolute return false for ~ on Ubuntu #29164

Description

@arxeiss
  • Version: v12.8.0
  • Platform: Ubuntu 19.04 (Linux 5.0.0-23-generic Simple project messaging. #24-Ubuntu SMP Mon Jul 29 15:36:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux)

I'm checking if given path in config file is absolute or relative. It works great however not when ~ is used. Then it returns false.

Here is my code

import path from 'path';

path.isAbsolute('/var/www/index.html'); // true
path.isAbsolute('./index.html'); // false
path.isAbsolute('~/Documents/test.json'); // false - THIS IS BAD

Activity

  1. cjihrig commented on Aug 16, 2019

    @cjihrig
    Contributor

    The problem is that the path module doesn't know anything about expanding the ~ (that's a shell thing).

  2. added
    invalidIssues and PRs that are invalid.
    pathIssues and PRs related to the path subsystem.
    on Aug 16, 2019
  3. bnoordhuis commented on Aug 16, 2019

    @bnoordhuis
    Member

    As Colin mentions, the path module doesn't do shell expansion. Closing, not a bug.

  4. arxeiss commented on Aug 19, 2019

    @arxeiss
    Author

    Sorry guys, my fault. I always thought that ~ is regular path descriptor for Linux, not a shell thing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssues and PRs that are invalid.pathIssues and PRs related to the path subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions