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

skipRegex seems to be broken in 0.12.2 (verified, patch in progress) #3682

Closed
dottodot opened this issue Apr 2, 2016 · 9 comments
Closed
Assignees
Labels

Comments

@dottodot
Copy link

dottodot commented Apr 2, 2016

Sails version: 0.12.2
Node version: 5.10.0 & 4.3.1
NPM version: 3.8.5 & 2.14.6
Operating system: Mac OSX 10.11.3


On 0.12.1 the following allowed me to access my routes starting /api without rendering a view but on 0.12.2 it now renders the view

module.exports.routes = {
  '/*': {
     view: 'homepage',
     skipAssets: true,
     skipRegex: /(^\/api\/.*$)|^\/csrfToken$/
   }
};
@sailsbot
Copy link

sailsbot commented Apr 2, 2016

Hi @dottodot! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:

  • Verify "I am experiencing a concrete technical issue (aka a bug) with Sails (ideas and feature proposals should follow the guide for proposing features and enhancements (http://bit.ly/sails-feature-guide), which involves making a pull request). If you're not 100% certain whether it's a bug or not, that's okay--you may continue. The worst that can happen is that the issue will be closed and we'll point you in the right direction."
  • Verify "I am not asking a question about how to use Sails or about whether or not Sails has a certain feature (please refer to the documentation(http://sailsjs.org), or post on http://stackoverflow.com, our Google Group (http://bit.ly/sails-google-group) or our live chat (https://gitter.im/balderdashy/sails)."
  • Verify "I have already searched for related issues, and found none open (if you found a related closed issue, please link to it in your post)."
  • Verify "My issue title is concise, on-topic and polite ("jst.js being removed from layout.ejs on lift" is good; "templates dont work" or "why is sails dumb" are not so good)."
  • Verify "I have tried all the following (if relevant) and my issue remains:"
  • Verify "I can provide steps to reproduce this issue that others can follow."

As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!

If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@treeline.io.

@dottodot
Copy link
Author

dottodot commented Apr 2, 2016

OK Fixed

@nikhilbedi
Copy link

@dottodot Yep. I only use the following for my single page application:
'/*': { view: 'homepage', skipAssets: true }

I believe skipAssets is broken transitioning from 0.12.1 to 0.12.2.

@AlexanderKozhevin
Copy link

+1. It's definitely broken. I used to use regExp too. Things work fine except Assets in version 0.12.5 They are not loaded property - wrong type.

Resource interpreted as Stylesheet but transferred with MIME type text/html

  "r|^\/(?!.*api).*|":{
        view: 'homepage',
        skipAssets: true
  }

But in 0.11.5 everything is fine.

@mikermcneil
Copy link
Member

@nikhilbedi @AlexanderKozhevin @dottodot Thanks for the report guys. Looking into it momentarily.

docs link for reference

@mikermcneil mikermcneil added the bug label Apr 4, 2016
@mikermcneil
Copy link
Member

Verified on Node 4 (repro). I've got a general idea of what might be going on, but I want to add a few tests first just to make sure (and to avoid any future regressions). We'll release a follow-up patch ASAP this morning.

@nikhilbedi @AlexanderKozhevin @dottodot Thanks again for your help!

@mikermcneil mikermcneil self-assigned this Apr 4, 2016
@mikermcneil mikermcneil changed the title skipRegex seems to be broken in 0.12.2 skipRegex seems to be broken in 0.12.2 (verified, patch in progress) Apr 4, 2016
mikermcneil added a commit that referenced this issue Apr 4, 2016
@mikermcneil
Copy link
Member

Confirmed that skipAssets and skipRegex are currently working with controller+action route targets; the issue is specifically with view targets. Should have a fix ready momentarily.

@mikermcneil
Copy link
Member

So the issue here was that when the view hook was changed to solve issues with explicit routing to deeply nested static views, core options were no longer being passed through from the view hook, causing core options like skipAssets and skipRegex to be ignored (since they weren't passed back to .bind()).

These options were already well tested for controllers+actions, but there weren't yet tests in core for direct routing to views (i.e. using {view: 'foo/bar'} route target syntax). The issue is now resolved, and I added new tests that specifically check for this case to ensure there aren't regressions. Will publish sails@0.12.3 with this included momentarily.

@mikermcneil
Copy link
Member

Fix published in sails@0.12.3:

npm install sails@latest --save --save-exact

ctartist621 added a commit to ctartist621/sails that referenced this issue Apr 6, 2016
0.12.3

* tag 'v0.12.3':
  0.12.3
  Clarify that these type of view filenames (i.e. with extra dots) are not allowed (in assertion msg.)
  Update changelog.
  Fixes balderdashy#3682
  Cleanup in route:typeUnknown event handler.
  Apply coding conventions.
  Trivial (clearer variable name for usage of sailsUtil to facilitate future cleanup).
  Added a couple of tests to ensure skipAssets is working as expected for controller/action route targets. (it is)
  Assorted cleanup of existing test file including skipAssets.
  Adjust todo.
  Add failing test re balderdashy#3682
  Stub out skipAssets test- extracting the improved helper that spawns a child proce that performs sails lift along the way.
  Switch to chalk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants