[interchange-cvs] interchange - docelic modified code/Filter/liven_urls.filter

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Mon Sep 5 06:33:50 EDT 2005


User:      docelic
Date:      2005-09-05 10:33:50 GMT
Modified:  code/Filter liven_urls.filter
Log:
* Recognize https:// urls (handled by "http" regexp, not a separate one)

* Make match case insensitive, that is, also match things like HTTP://

* I also benchmarked a situation where I would precompile regexps,
  but probably Perl figures that by itself so it's not needed.
  (I ran the test on 40,000 URLs, and in both cases results were between
  1.310 and 1.330 seconds).

Revision  Changes    Path
1.2       +3 -3      interchange/code/Filter/liven_urls.filter


rev 1.2, prev_rev 1.1
Index: liven_urls.filter
===================================================================
RCS file: /var/cvs/interchange/code/Filter/liven_urls.filter,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- liven_urls.filter	11 Aug 2005 23:21:22 -0000	1.1
+++ liven_urls.filter	5 Sep 2005 10:33:49 -0000	1.2
@@ -1,7 +1,7 @@
 # Copyright 2005 Davor Ocelic (docelic at mail.inet.hr)
 # Copyright 2005 Interchange Development Group (http://www.icdevgroup.org/)
 # Licensed under the GNU GPL v2. See file LICENSE for details.
-# $Id: liven_urls.filter,v 1.1 2005/08/11 23:21:22 docelic Exp $
+# $Id: liven_urls.filter,v 1.2 2005/09/05 10:33:49 docelic Exp $
 
 CodeDef liven_urls Filter
 CodeDef liven_urls Description Make URLs clickable
@@ -10,7 +10,7 @@
 my %regexps = (
 
 http => <<'ENDR',
-(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))?)?)
+(?:https?://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))?)?)
 ENDR
 
 
@@ -106,7 +106,7 @@
 	@arg or return $val;
 	my $match_url = join '|', @regexps{@arg};
 
-	$val =~ s/($match_url)/<a href="$1">$1<\/a>/gs;
+	$val =~ s/($match_url)/<a href="$1">$1<\/a>/gsi;
 	$val
 }
 EOR








More information about the interchange-cvs mailing list