From 2b84feb29f1ca113a0f2d79d0e7872b5a1d98c4a Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 23 May 2002 04:46:37 +0000 Subject: [PATCH] Change urlize function so that it removes all leading and trailing whitespace from the string. --- lib/WebGUI/URL.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/URL.pm b/lib/WebGUI/URL.pm index 92203555f..655212512 100644 --- a/lib/WebGUI/URL.pm +++ b/lib/WebGUI/URL.pm @@ -81,12 +81,14 @@ sub unescape { #------------------------------------------------------------------- sub urlize { - my ($title); - $title = lc($_[0]); - $title =~ s/ /_/g; - $title =~ s/\.$//g; - $title =~ s/[^a-z0-9\-\.\_]//g; - return $title; + my ($value); + $value = lc($_[0]); #lower cases whole string + $value =~ s/\W+$//g; #removes trailing whitespace + $value =~ s/^\W+//g; #removes leading whitespace + $value =~ s/ /_/g; #replaces whitespace with underscores + $value =~ s/\.$//g; #removes trailing period + $value =~ s/[^a-z0-9\-\.\_]//g; #removes all funky characters + return $value; }