Tweaking handling of initial slash detection to handle initial undefs.
This commit is contained in:
parent
7172af61e1
commit
a316c58217
7
Utils.pm
7
Utils.pm
@ -49,9 +49,7 @@ our @EXPORT_OK = qw(path_join resolve_path check_directory load_file save_file s
|
||||
# @return A string containing the path fragments joined with forward slashes.
|
||||
sub path_join {
|
||||
my @fragments = @_;
|
||||
|
||||
# Need a lead slash?
|
||||
my $leadslash = $fragments[0] =~ m|^/|;
|
||||
my $leadslash;
|
||||
|
||||
# strip leading and trailing slashes from fragments
|
||||
my @parts;
|
||||
@ -59,6 +57,9 @@ sub path_join {
|
||||
# Skip empty fragments.
|
||||
next unless($bit);
|
||||
|
||||
# Determine whether the first real path has a leading slash.
|
||||
$leadslash = $bit =~ m|^/| unless(defined($leadslash));
|
||||
|
||||
# Remove leading and trailing slashes
|
||||
$bit =~ s|^/*||; $bit =~ s|/*$||;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user