Sails: skipRegex seems to be broken in 0.12.2 (verified, patch in progress)

Created on 2 Apr 2016  路  9Comments  路  Source: balderdashy/sails

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$/
   }
};
bug

Most helpful comment

Fix published in [email protected]:

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

All 9 comments

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 [email protected]._

OK Fixed

@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.

+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.

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

docs link for reference

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!

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.

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 [email protected] with this included momentarily.

Fix published in [email protected]:

npm install sails@latest --save --save-exact
Was this page helpful?
0 / 5 - 0 ratings