Add tests to cover the removal of extensions in the "directory"

parts of the path.  Refactor out the while loop with match and
nested s/// into a single regexp.
This commit is contained in:
Colin Kuskie 2007-12-16 04:13:53 +00:00
parent cda571c3ef
commit b70ef9d23a
2 changed files with 11 additions and 4 deletions

View file

@ -583,9 +583,10 @@ sub fixUrl {
}
# remove multiple extensions from the url if there are some
while ($url =~ m{^(.*)\.\w+(/.*)$}) {
$url =~ s{^(.*)\.\w+(/.*)$}{$1$2}ig;
}
$url =~ s{
(\.\w+)* # Strip off any number of extensions
(?=/) # Followed by a slash
}{}xg; # And delete all of them in the string
# add automatic extension if we're supposed to
if ($self->session->setting->get("urlExtension") ne "" #don't add an extension if one isn't set