A regular expression designed for use in identifying URL paths that seem like they are probably for a static asset of some kind (e.g. image, stylesheet, favicon.ico
, robots.txt
, etc.).
sails.LOOKS_LIKE_ASSET_RX;
Type:
This regex is by no means foolproof, and may match URLs too aggressively for some applications. It is just a reasonable approximation made available for convenience.
To avoid disabling built-in session support for any request to a URL path that ends in .json
, but still disable sessions for other requests for static assets, you might use the following configuration:
// In `config/session.js`
isSessionDisabled: function (req){
if (req.path.match(/\.json$/)) {
// Don't disable sessions.
return;
}
var seemsToWantSomeOtherStaticAsset = !!req.path.match(sails.LOOKS_LIKE_ASSET_RX);
if (seemsToWantSomeOtherStaticAsset) {
// Disable sessions.
return true;
}
// Otherwise, don't disable sessions.
return;
}