From: Chris W. <la...@us...> - 2004-11-25 03:51:53
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12917/lib/OpenInteract2 Modified Files: URL.pm Log Message: add strip_deployment_context() method to OI2::URL, plus tests Index: URL.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/URL.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** URL.pm 24 Nov 2004 14:16:01 -0000 1.26 --- URL.pm 25 Nov 2004 03:51:44 -0000 1.27 *************** *** 186,189 **** --- 186,206 ---- } + ######################################## + # URL REMOVAL + + sub strip_deployment_context { + my ( $class, $url ) = @_; + return '' unless ( $url ); + return '/' if ( $url eq '/' ); + return '' if ( $url eq DEPLOY_URL ); + + # Since we've taken care of the '/context' case with the previous + # statement we can assume any deployment context ends with a '/' + + my $deployment_context = DEPLOY_URL; + $url =~ s|^$deployment_context/|/|; + return $url; + } + 1; *************** *** 544,547 **** --- 561,569 ---- # $url_with_params = '/foo/bar?keep=no&id=55&undercover=yes + B<strip_deployment_context( $url )> + + Removes any deployment context from C<$url> and returns the modified + string. + =head1 SEE ALSO |