Change urlize function so that it removes all leading and trailing whitespace from the string.

This commit is contained in:
JT Smith 2002-05-23 04:46:37 +00:00
parent c7a5183369
commit 2b84feb29f

View file

@ -81,12 +81,14 @@ sub unescape {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub urlize { sub urlize {
my ($title); my ($value);
$title = lc($_[0]); $value = lc($_[0]); #lower cases whole string
$title =~ s/ /_/g; $value =~ s/\W+$//g; #removes trailing whitespace
$title =~ s/\.$//g; $value =~ s/^\W+//g; #removes leading whitespace
$title =~ s/[^a-z0-9\-\.\_]//g; $value =~ s/ /_/g; #replaces whitespace with underscores
return $title; $value =~ s/\.$//g; #removes trailing period
$value =~ s/[^a-z0-9\-\.\_]//g; #removes all funky characters
return $value;
} }