balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.82k stars 1.95k forks source link

Wildcard/"Vanity URL" routing with exclusion does not work (example in routes.js invalid) #1021

Closed wiledal closed 10 years ago

wiledal commented 10 years ago

We have a SpineJS-based application that we're migrating to 0.9.x from 0.8.x. All routes should lead to the same static index-file, with exceptions set up for model CRUD etc.

The below makes all requests go to index:

'get /*': {
  view: 'static/index'
}

The following solution is included in the comments of routes.js that is generated with sails new <app name>:

'get /*(^.*)': {
  view: 'static/index'
}

This is supposed to ignore requests ending with a file-extension, but instead seems to be unmatched completely.

0xsven commented 10 years ago

I am also interested in solving this issue.

dettmar commented 10 years ago

Same issue here, on 0.9.7.

mikermcneil commented 10 years ago

@wiledal @dettmar @0xsven thanks for the heads up

I have a hunch that the string regex doesn't actually work, in Express or Sails (which is my bad- I realize it was in the example at some point). @sgress454 looked into this a bit Friday and had some preliminary ideas about how to solve this. Seems that Express' tolerance of regex-like strings is limited, and may also have changed a bit across 3.x patch versions (I could be wrong there though, that's off the top of my head)

I renamed the issue, since the bad example is removed in 0.10.

Thanks!

mikermcneil commented 10 years ago

actually, just going to recreate the issue and link back to keep the two things separate for housekeeping. Thanks again!

mikermcneil commented 10 years ago

See https://github.com/balderdashy/sails/issues/1458