[Coldbox 4.1.0] routes - _INVALID_VARIABLE_NAME_POS

Hello!

Get an error msg variable in rc called “INVALID_VARIABLE_NAME_POS_[x]_” that I think shouldn’t be there. Has to do with routes.

routes.cfm

addRoute(pattern="/test/", handler=“main”, action=“test” );
addRoute(pattern=":handler/:action?");

url
/test/something-something/blah

rc dump

Struct
INVALID_VARIABLE_NAME_POS_1
string blah

event
string main.test

namespace
string

namespaceRouting
string

main.test simply does

function test(event,rc,prc){
writedump(var=rc, abort=true);
}

It seems like with route /test/ passing that additional variable matching stuff would stop. I see the error message is coming from ses.cfc function “findConventionNameValuePairs”. I suppose if doesn’t log it anywhere and pollute logs is ok but wondering if is proper. If I change something-something to underscore everything is fine so it’s looking at that string even though reporting “blah” as bad value.

??

Thank you!

Irv

You’re not matching your “/test/” route since that isn’t what the URL has in it. You’re hitting the second default route and the breakdown is like this:

handler: test
action: something-something
extra!!: blah

I assume you want to add a question mark to the end of your test route so it will match additional name/value pairs.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

??

It’s definitely hitting the test route. Main.test is what’s running. Again, I’m testing with /test/something-something/blah or more completely maybe xyz.com/test/something-something/blah

Am I missing something??

A more “real world” example might be helpful. Let’s say you’ve got a job vacancy site and you have the URL

somejobsite.com/job/forklift-operator-harrisburg-pa/21345

routes.cfm has
addRoute(pattern="/job/", handler=“vacancy”, action=“showposition” );
addRoute(pattern=":handler/:action?");

In vacancy.showposition() I can easily get the job # (21345) with listlast(url,"/") but that little error msg var in rc is annoying. Not sure if should be there or not.

Hope this helps.

Irv

The issue appears to be with a hyphen in the url part. You’d have to trace through the SES interceptor to figure why it’s happening. Maybe put in a bug as well.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad,

Found it. Route in routes.cfm should have been addRoute(pattern="/test/", handler=“main”, action=“test”, valuePairTranslation=“false”); . Just need to add valuePairTranslation=“false” to tell ses.cfc not to look for name/value pairs.

Thanks!

Irv

But I thought you wanted the key/value translation? Don’t you want to access rc[ ‘forklift-operator-harrisburg-pa’ ] and get a value of 21345? If not, what’s the purpose of them in the route since you’re not matching them with route placeholders and they’re not part o the actual route?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Using a job posting site as an example today we have

/job/21345

the routes.cfm entry addRoute(pattern="/job/:jobordernumber-numeric", handler=“vacancy”, action=“showposition” ); captures 21345 as rc.jobOrderNumber for handler vacancy.showposition()

Now I’ve spoken to an SEO guy and read a little online and we might be interested in the (perhaps marginal) SEO boost we would get with

/job/forklift-operator-harrisburg-pa/21345

In this example the job ID is still 21345 and the descriptive stuff is just that - descriptive text for url. So now my routes.cfm entry is

addRoute(pattern="/job/", handler=“vacancy”, action=“showposition”, valuePairTranslation=“false” ); and in handler vacancy.showposition() I’m using var jobOrderNumber = VAL( trim( listlast( prc.currentRoutedURL, ‘/’ ) ) );

It seems to work and I’m not seeing any downfalls to it. If there’s a better way I’m all for it. Just wanted to explain why the extraneous text is in the URL.

Thank you!

Irv

Forgot to mention that might be easier and cleaner as /job/21345/forklift… but I was taking my clue from another non-job site (grubhub) that does pretty much exact thing I’m looking at. As sort of confirmation how theirs works if you take the url below and butcher any of the text in the “descriptive” section between “restaurant/” and “/264637” you’ll still wind up in the same place. I suppose it’s done this way for the whole “relevancy vs. how many subfolders down” sort of thing…maybe.

https://www.grubhub.com/restaurant/corleones-paradise-valley-tatum-blvd-10637-n-tatum-blvd-phoenix/264637

Yeah, that doesn’t really make any sense since the SES interceptor is there to parse the path info for you, but you’re basically trying to do it all manually yourself. If you know each route will have some useless text bits and then a job number, then build those into the actual route so Coldbox can capture them for you!

addRoute( pattern="/test/:junk/:jobid", handler=“main”, action=“test”);

And if you don’t even want the rc.junk variable, just match the text bits with regex:

addRoute( pattern="/test/regex:.*/:jobid", handler=“main”, action=“test”);

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Doesn’t really matter the order it comes in. For what it’s worth, I’ve heard that Google doesn’t really pay much attention to your URLs, at least not any longer. It’s really the content of your site that matters. That said, ColdBox can be configured to match whatever you need.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad, that was very helpful! Tried out both and either works exactly for what I need. Thank you!

Irv