RE: Enhancement for Router to ignore double slashes?

2008-11-10 Thread Jerome Louvel
Hi guys,
 
This is definitely an interesting suggestion Avi! I do like Rob's generic
solution as well:
 
Automatically normalize URIs
http://restlet.tigris.org/issues/show_bug.cgi?id=650
 
See my comments inside the RFE and let's discuss the design details there
maybe.
 
Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~  http://www.restlet.org/
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  http://www.noelios.com/
http://www.noelios.com


  _  

De : Rob Heittman [mailto:[EMAIL PROTECTED] 
Envoyé : mercredi 5 novembre 2008 21:49
À : discuss@restlet.tigris.org
Objet : Re: Enhancement for Router to ignore double slashes?


I exist to create work for Jerome and Thierry.

 

Makes sense to me! But do Router/Route/Template currently use
Reference.getTargetRef() as part of their normal operation, when
trying to match a request URL to a Route? If not, that might be a
pretty significant change to some core code.





Re: Enhancement for Router to ignore double slashes?

2008-11-05 Thread Avi Flax
On Mon, Nov 3, 2008 at 19:09, Avi Flax [EMAIL PROTECTED] wrote:

 ...I'm interested in a way to put the
 Router or the Route into a mode wherein they would ignore the double
 slashes somehow, or collapse them together into a single slash. I
 tried to follow the Routing code but I couldn't figure it out.

 So my question: would there be interest in an enhancement such as
 this? Or does anyone have a suggestion on how to achieve this via
 filters or services or something like that?

Not much interest in this, apparently, which is fine, but I'm still
interested, so I'll keep going.

I've figured out how to have a Filter, placed in the chain before a
Router, remove double-slashes:

@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();

String originalPath = ref.getPath();

if (originalPath.contains(//))
{
String newPath = originalPath.replaceAll(//, /);
ref.setPath(newPath);
}

return Filter.CONTINUE;
}

This works just fine. (I know the regex should probably be more
sophisticated, but this is more about a proof of concept than
production-ready code.) But I'd be interested in having this
functionality be built into the framework; using a syntax something
like:

router.setIgnoreDoubleSlashes(true);

or maybe:

router.setIgnoreCommonTypos(true);

So I'll ask one more time: would anyone else like to see this feature
make it into the API?

-- 
Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com