Skip to content

path.relative on windows returns incorrect result #17413

Closed
@TanninOne

Description

@TanninOne
  • Version: tested with v7.7.4 and v9.2.0
  • Platform: Windows 10 (64-bit)
  • Subsystem: path

Code says it best:

> path.relative('c:', 'c:\\test')
'..\\..\\test'
> path.relative('c:', 'c:/test') 
'..\\..\\test'

Not sure why c: is treated differently here, but for all other volumes it returns the right result:

> path.relative('d:', 'd:\\test')
'test'
> path.relative('d:', 'd:/test') 
'test'

also it appears to happen only on the root level:

> path.relative('c:\\test', 'c:\\test\\sub')
'sub'

and only if the colon is the last character of the base path

> path.relative('c:\\', 'c:\\test')
'test'

Metadata

Metadata

Assignees

No one assigned

    Labels

    pathIssues and PRs related to the path subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions