From: Chris W. <la...@us...> - 2005-02-26 23:22:54
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32729/lib/OpenInteract2 Modified Files: URL.pm Log Message: OIN-135: modify URL parsing to deal with additional parameters and return from parse() methods Index: URL.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/URL.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** URL.pm 27 Nov 2004 18:27:33 -0000 1.28 --- URL.pm 26 Feb 2005 23:22:45 -0000 1.29 *************** *** 53,60 **** } ! my ( $action_name ) = $path =~ m|^/([^/?]+)|; ! my ( $task ) = $path =~ m|^/[^/]+/([^/?]+)|; ! ! return ( $action_name, $task ); } --- 53,60 ---- } ! my @path_items = split( /\//, $path ); ! shift @path_items unless ( $path_items[0] ); ! pop @path_items unless ( $path_items[-1] ); ! return ( @path_items ); } *************** *** 274,290 **** B<parse( $url )> ! Parses C<$url> into an action name and task, disregarding the URL ! context. It does not attempt to verify whether the action name or the ! task is valid. This should only be used on relative URLs, or ones ! already stripped by the L<OpenInteract2::Request|OpenInteract2::Request> object. ! Note that an action name and task are still returned if an application ! is deployed under a context and the URL does not start with that ! context. See C<parse_absolute()> for a version that takes this into ! account. ! Return: two-item list of the action name and task pulled from ! C<$url>. Note that the second item may be undefined. Examples: --- 274,291 ---- B<parse( $url )> ! Parses C<$url> into an action name and task and any additional ! parameters, disregarding the URL context. It does not attempt to ! verify whether the action name or the task is valid. This should only ! be used on relative URLs, or ones already stripped by the L<OpenInteract2::Request|OpenInteract2::Request> object. ! Note that an action name, task and parameters are still returned if an ! application is deployed under a context and the URL does not start ! with that context. See C<parse_absolute()> for a version that takes ! this into account. ! Return: list with the action name and task and additional parameters ! pulled from C<$url>; if the C<$url> is empty or just a single '/' the ! list will be empty as well. Examples: *************** *** 294,297 **** --- 295,301 ---- # $action_name = 'games', $task = 'explore' + my ( $action_name, $task, @params ) = OpenInteract2::URL->parse( '/games/explore/1' ); + # $action_name = 'games', $task = 'explore', $params[0] = '1' + CTX->assign_deploy_url( '/Public' ); my ( $action_name, $task ) = OpenInteract2::URL->parse( '/games/explore/' ); *************** *** 302,305 **** --- 306,313 ---- # $action_name = 'games', $task = undef; + CTX->assign_deploy_url( '/Public' ); + my ( $action_name, $task, @params ) = OpenInteract2::URL->parse( '/games/display/42/?foo=bar' ); + # $action_name = 'games', $task = 'display', $params[0] = '42'; + my ( $action_name, $task ) = OpenInteract2::URL->parse( '/Public/games/explore/' ); # $action_name = 'games', $task = 'explore' *************** *** 307,310 **** --- 315,321 ---- my ( $action_name, $task ) = OpenInteract2::URL->parse( '/Public/games/?foo=bar' ); # $action_name = 'games', $task = undef + + my ( $action_name, $task, @params ) = OpenInteract2::URL->parse( '/Public/games/explore/55?foo=bar' ); + # $action_name = 'games', $task = 'explore', $params[0] = '55' B<Alias>: C<parse_relative( $url )> *************** *** 334,337 **** --- 345,351 ---- # $action_name = 'games', $task = 'explore' + my ( $action_name, $task, @params ) = OpenInteract2::URL->parse_absolute( '/Public/games/explore/42' ); + # $action_name = 'games', $task = 'explore', $params[0] = '42' + my ( $action_name, $task ) = OpenInteract2::URL->parse_absolute( '/Public/games/?foo=bar' ); # $action_name = 'games', $task = undef *************** *** 371,375 **** Finally: if C<$base_url> begins with 'http:' we do not modify it in ! any way (including escaping it) except to append the C<\%params>. Return: URL formed from the deployed context, C<$base_url> and --- 385,390 ---- Finally: if C<$base_url> begins with 'http:' we do not modify it in ! any way (including escaping it or adding a context) except to append ! the C<\%params>. Return: URL formed from the deployed context, C<$base_url> and *************** *** 402,405 **** --- 417,423 ---- # $url = '/Public/foo?name=Mario%20Lemiux' + $url = OpenInteract2::URL->create( 'http://foo bar/foo', { name => 'Mario Lemieux' } ); + # $url = 'http://foo bar/foo?name=Mario%20Lemiux' + CTX->assign_deploy_url( '/cgi-bin/oi.cgi' ); $url = OpenInteract2::URL->create( '/foo', { bar => 'baz' } ); |