On Thu, 2 Aug 2007, Alexandru Stanoi wrote: > From what I understand, issue #10896 (http://issues.ez.no/10896) asks > that URLs of this form: > (1) http://www.example.com/(param1)/a/(param2)/x/(param2)/y > > are treated as if they are of this form: > (2) http://www.example.com/(param1)/a/(param2)/x/y > > Is this correct?
I don't see how this is mentioned in the report. To me it just looks like case (1) should be supported as well. > In the second case (2) things are normal, but you must specify > MULTIPLE_ARGUMENTS for param2 to get all its values in an array: > > <code> > $urlCfg = new ezcUrlConfiguration(); > $urlCfg->addUnorderedParameter( 'param1' ); > $urlCfg->addUnorderedParameter( 'param2', > ezcUrlConfiguration::MULTIPLE_ARGUMENTS ); > > $url = new ezcUrl( 'http://www.example.com/(param1)/a/(param2)/x/y', $urlCfg > ); > > $param1 = $url->getParam( 'param1' ); // returns "a" > $param2 = $url->getParam( 'param2' ); // returns array( "x", "y" ) > </code> > > > > In the first case, as it is now, even if you specify MULTIPLE_ARGUMENTS > for param2, only the last value encountered is returned: > > <code> > $urlCfg = new ezcUrlConfiguration(); > $urlCfg->addUnorderedParameter( 'param1' ); > $urlCfg->addUnorderedParameter( 'param2' ); > > $url = new ezcUrl( > 'http://www.example.com/(param1)/a/(param2)/x/(param2)/y', $urlCfg ); > > $param1 = $url->getParam( 'param1' ); // returns "a" > $param2 = $url->getParam( 'param2' ); // returns "y" > </code> > > > The feature request tries to implement returning all the values for > param2 in an array. > > > But how should this be handled? > > - should param2 be array( "x", "y" ) by default, even if > MULTIPLE_ARGUMENTS are not specified for it? No, as this makes it possible to break an application's assumptions for always getting a string by specifying the same parameter twice. > - should param2 be array( "x", "y" ) by default, only if > MULTIPLE_ARGUMENTS are specified for it? No, as this "(param2)/x/(params2)/y" is a different case than "(param2)/x/y". > - should param2 be array( "x", "y" ) only if a third parameter is > specified for the addUnorderedParameter() function? Yes, but instead of using a third parameter, I would instead use a different constant as second parameter. > - should the URL be recreated (with buildUrl()) to form (1) (eventually > based on a parameter of buildUrl() or addUnorderedParameter())? > > - should the URL be recreated (with buildUrl()) to form (2) (eventually > based on a parameter of buildUrl() or addUnorderedParameter())? Both examples should return back to the original string after running buildUrl() on the processed Url. regards, Derick -- Components mailing list [email protected] http://lists.ez.no/mailman/listinfo/components
