But it appears the underscore is playing a different role and is being included in the :lastname parameter, instead of being a seperator. Can you advise how I should correctly route the above path?
It’s also strangely (with the above string) cutting off the first letter of the :firstname parameter when I look at the response in the network tab.
The name of route parameters is made up of “word characters” ([A-Za-z0-9_]). The route example.com/level1/:firstname-:lastname_:id will result in the parameters firstname, lastname_ and id. You see that the _ will be part of the parameter. To separate parameters in a path use /, - or ..
Thanks Patrick, is there any way to include an underscore that does not consider itself part of the parameter?
The reason why I’d like to use underscore is we are migrating an existing, live site and all the url paths have an underscore, the minute we remove them, we’ll lose have dead links and take a big hit in traffic.
Unfortunately didn’t work - page doesn’t pick up the data - if I type [] in the actual browser url path it works, but if I use this in the routing and then just have :lastname:id it doesn’t work or pick up data
Then adding a route path with /level1/:firstname-:lastname[_]:id should work, using a browser url like example.com/level1/patrick-woldberg_1 it should return the params firstname=patrick, lastname=woldberg and id=1.
I created the route path as you suggested or e.g. (/recruiters/:firstname-:lastname[_]:id), and then created a dynamic link on the page. When I click save the path changes to this:
And this transfers to the URL when rendered and clicked:
Which is naturally not the desired result. Can you please advise?
The problem is with the _, if you change that to a - or / then it would have no problems with the path. I will do some testing to see if the _ will give me the same problems.