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

Reply via email to