Project

General

Profile

Actions

Feature #7412

open

Pathname#relative_path_from does not support mixed directory separators on windows

Added by 7er (Syver Enstad) over 11 years ago. Updated about 6 years ago.

Status:
Assigned
Target version:
-
[ruby-core:49666]

Description

=begin
The support for mixing backslashes and forward slashes in the pathname module in the standard library seems to be broken on windows

require 'pathname'
base = Pathname.new("c:\\")
filepath = Pathname.new("c:/foo/bar/file.ext")
base.relative_path_from(filepath)

raises ArgumentError: different prefix: "c:\\" and "c:/foo/bar/file.ext"

Changing filepath to contain backslashes fixes the problem

filepath = Pathname.new("c:\\foo\\bar\\file.ext")
base.relative_path_from(filepath)

=> #<Pathname:../../..>
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0