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.
|
# @return A string containing the path fragments joined with forward slashes.
|
||||||
sub path_join {
|
sub path_join {
|
||||||
my @fragments = @_;
|
my @fragments = @_;
|
||||||
|
my $leadslash;
|
||||||
# Need a lead slash?
|
|
||||||
my $leadslash = $fragments[0] =~ m|^/|;
|
|
||||||
|
|
||||||
# strip leading and trailing slashes from fragments
|
# strip leading and trailing slashes from fragments
|
||||||
my @parts;
|
my @parts;
|
||||||
@ -59,6 +57,9 @@ sub path_join {
|
|||||||
# Skip empty fragments.
|
# Skip empty fragments.
|
||||||
next unless($bit);
|
next unless($bit);
|
||||||
|
|
||||||
|
# Determine whether the first real path has a leading slash.
|
||||||
|
$leadslash = $bit =~ m|^/| unless(defined($leadslash));
|
||||||
|
|
||||||
# Remove leading and trailing slashes
|
# Remove leading and trailing slashes
|
||||||
$bit =~ s|^/*||; $bit =~ s|/*$||;
|
$bit =~ s|^/*||; $bit =~ s|/*$||;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user