Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirectTo() helper does not accept "/" as action #20

Open
botic opened this issue Aug 26, 2011 · 0 comments
Open

redirectTo() helper does not accept "/" as action #20

botic opened this issue Aug 26, 2011 · 0 comments
Milestone

Comments

@botic
Copy link
Member

botic commented Aug 26, 2011

I think this is a bug in the reverse lookup with "/". If I change the binding to {action: "/someAction" } it works as expected.

var {Application} = require("stick");
var {redirectTo} = require("stick/helpers"); 
var log = require("ringo/logging").getLogger(module.id);
var fs = require("fs");

var app = exports.app = Application();

var response = require("ringo/jsgi/response");

app.configure("params", "upload", "route");

app.post("/uploadImage", function(req) {
   if (req.postParams.formFileInput && req.postParams.formFileInput.value.length > 0) {
      fs.write(module.resolve("files/" + req.postParams.formFileInput.filename), req.postParams.formFileInput.value);

      // This redirects to http://localhost:8080/upload/_/_(unknown_route)
      return redirectTo(app, {
         action: "/"  // <----- FAILS with: Error: Unhandled request (stick/lib/stick.js#193) 
      });
   }

   return response.html("<html><body><h1>Upload failed.</h1></body></html>");
});

app.get("/", function(req) {
   return response.html("<html><head><title>File Upload Demo</title></head> \
         <body><form method='POST' action='uploadImage' enctype='multipart/form-data'> \
         <h1>Upload:</h1> \
         <input type='file' name='formFileInput' /><hr/><input type='submit' value='Upload' /> \
         </form></body> \
      </html>");
});
@botic botic added this to the 1.0 milestone Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant