Skip to content

Allow redirect() method to convert routes into SES links #556

@charlesr1971

Description

@charlesr1971

Hi Guys

I was talking to Sean Corfield, a few months ago about adding a backward compatible enhancement to the redirect() method:

https://cfml.slack.com/archives/C06TA3B3L/p1709743825550009

Here is the gist of my idea:

I have created a redirect:

variables.fw.redirect(action='question.form',append="questionid");

Which displays:

https://www.foo.com/question/form/questionid/31

But I also have a route:

generateSES = true,
SESOmitIndex = true,
routes = [
    {"$*/question/edit/questionid/([0-9]+)/?$" = "/question/form/questionid/\1"},

Surely, the redirect() & buildURL() methods, should add the route conversion as well?

So, I would expect the following to be displayed in the address bar:

https://www.foo.com/question/edit/questionid/31

Have I uncovered a bug, or maybe these methods do not analyze the routes, when converting links into SES links.

And Sean replied:

Routing is unidirectional: it's applied inbound on requests, not outbound on responses (so redirect() and buildURL() do not consider route mappings). It's an interesting potential enhancement -- but no one's maintaining FW/1 these days so it is very unlikely to get added, unless you decide to implement it and submit a PR.

New signature:

This is what I reckon the new signature for the redirect() method could be:

public void function redirect( 
    string action,
    string preserve = “none”,
    string append = “none”,
    string path = see below,
    any queryString = ‘’,
    string statusCode = ‘302’,
    string header = ‘’,
    boolean applyRoute = false
)

So the new param would be applyRoute

I would be happy to add this change, if you would like:

https://www.linkedin.com/in/charles-robertson-48313812

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions