Skip to content

Commit

Permalink
Ensure absolute base paths are absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Feb 5, 2017
1 parent 80896aa commit fad99e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ Revision history for Path-Tiny

{{$NEXT}}

[Changes]

- The 'absolute' method now always returns an absolute path, even if a
user provided a relative path for the base path. The old, odd
behavior was documented, but people often don't read docs. The new
behavior avoids suprises.

[Additions]

- Added 'cached_temp' method.
Expand Down
11 changes: 6 additions & 5 deletions lib/Path/Tiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ sub _resolve_symlinks {
$abs = path("foo/bar")->absolute("/tmp");
Returns a new C<Path::Tiny> object with an absolute path (or itself if already
absolute). Unless an argument is given, the current directory is used as the
absolute base path. The argument must be absolute or you won't get an absolute
result.
absolute). If no argument is given, the current directory is used as the
absolute base path. If an argument is given, it will be converted to an
absolute path (if it is not already) and used as the absolute base path.
This will not resolve upward directories ("foo/../bar") unless C<canonpath>
in L<File::Spec> would normally do so on your platform. If you need them
Expand All @@ -461,7 +461,7 @@ resolved, you must call the more expensive C<realpath> method instead.
On Windows, an absolute path without a volume component will have it added
based on the current drive.
Current API available since 0.001.
Current API available since 0.101.
=cut

Expand All @@ -486,7 +486,8 @@ sub absolute {

# relative path on any OS
require Cwd;
return path( ( defined($base) ? $base : Cwd::getcwd() ), $_[0]->[PATH] );
return path( ( defined($base) ? path($base)->absolute : Cwd::getcwd() ),
$_[0]->[PATH] );
}

=method append, append_raw, append_utf8
Expand Down

0 comments on commit fad99e3

Please sign in to comment.