routes containing dots

285 views
Skip to first unread message

Tom Sante

unread,
Jul 5, 2012, 11:12:50 AM7/5/12
to mojol...@googlegroups.com
Dear,

In my router I am trying to match a uid contained in my url like this:

/post/:uid

but if the ':uid' part contains a dot it isn't captured in the uid parameter but set as 'format'
Is there a way I can force it to ignore format matching and have ':uid' capture everything including dots?

So if a url is this:

/post/abcdef.ghe1
=> I want :uid = 'abcdef.ghe1'
=> but instead I now get :uid = 'abcdef' and format ='ghe1'

I could just concatenate uid and format with a dot in between but was hoping to avoid a workaround like that.

Thanks,

Tom


Gabriel Vieira

unread,
Jul 5, 2012, 12:55:55 PM7/5/12
to mojol...@googlegroups.com
http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Relaxed_placeholders
> --
> You received this message because you are subscribed to the Google Groups "Mojolicious" group.
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.
>



--
Gabriel Vieira

Tom Sante

unread,
Jul 5, 2012, 3:37:19 PM7/5/12
to mojol...@googlegroups.com
Yeah but my placeholder is at the end of the url not followed by something else.
It's the fact that the placeholder is at the end that mojo wants to make the 'format' be anything after the dot because its automatically detected and stored in the stash value 'format', and I don't want that.


.Op donderdag 5 juli 2012, om 18:55 heeft Gabriel Vieira het volgende geschreven:

> http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Relaxed_placeholders
>
> On Thu, Jul 5, 2012 at 12:12 PM, Tom Sante <tom....@gmail.com (mailto:tom....@gmail.com)> wrote:
> > Dear,
> >
> > In my router I am trying to match a uid contained in my url like this:
> >
> > /post/:uid
> >
> > but if the ':uid' part contains a dot it isn't captured in the uid parameter but set as 'format'
> > Is there a way I can force it to ignore format matching and have ':uid' capture everything including dots?
> >
> > So if a url is this:
> >
> > /post/abcdef.ghe1
> > => I want :uid = 'abcdef.ghe1'
> > => but instead I now get :uid = 'abcdef' and format ='ghe1'
> >
> > I could just concatenate uid and format with a dot in between but was hoping to avoid a workaround like that.
> >
> > Thanks,
> >
> > Tom
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Mojolicious" group.
> > To post to this group, send email to mojol...@googlegroups.com (mailto:mojol...@googlegroups.com).
> > To unsubscribe from this group, send email to mojolicious...@googlegroups.com (mailto:mojolicious...@googlegroups.com).
> > For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.
>
>
>
>
>
> --
> Gabriel Vieira
>
> --
> You received this message because you are subscribed to the Google Groups "Mojolicious" group.
> To post to this group, send email to mojol...@googlegroups.com (mailto:mojol...@googlegroups.com).
> To unsubscribe from this group, send email to mojolicious...@googlegroups.com (mailto:mojolicious...@googlegroups.com).

Gabriel Vieira

unread,
Jul 5, 2012, 9:55:08 PM7/5/12
to mojol...@googlegroups.com
Works fine here.

---------8<---------
use Mojolicious::Lite;

get '/#test' => sub {
my $self = shift;
$self->render_text( $self->param('test') );
};

app->start;
--------->8---------
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to mojolicious...@googlegroups.com.

Michael R. Davis

unread,
Mar 23, 2018, 6:05:33 PM3/23/18
to Mojolicious
On Thursday, July 5, 2012 at 11:12:50 AM UTC-4, Tom wrote:

In my router I am trying to match a uid contained in my url like this:

/post/:uid


 What Gabriel Vieira is trying to say is that a route with a colon is a "standard placeholder" that matches all but "." and "/".  But a route with a "#" is a relaxed placeholder and matches anything but "/" and then there is a route with a "*" wildcard placeholders that matches anything to end of URL.


Example

get '/add/:id/#param1/*param_rest'

Reply all
Reply to author
Forward
0 new messages