Change urlize function so that it removes all leading and trailing whitespace from the string.
This commit is contained in:
parent
c7a5183369
commit
2b84feb29f
1 changed files with 8 additions and 6 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue