connect-cors
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -0,5 +1,9 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
"use strict"; | ||
var create, defaultOrigins, defaultResources, defaults, escapeRegExp, isMSIE, msiePattern, operaPattern, selectNotEmpty, url; | ||
url = require("url"); | ||
defaults = { | ||
@@ -12,2 +16,3 @@ origins: [], | ||
}; | ||
defaultResources = [ | ||
@@ -18,5 +23,9 @@ { | ||
]; | ||
defaultOrigins = ['*']; | ||
msiePattern = /MSIE/i; | ||
operaPattern = /Opera/i; | ||
isMSIE = function(req) { | ||
@@ -34,2 +43,3 @@ var agent; | ||
}; | ||
selectNotEmpty = function(a, b) { | ||
@@ -44,5 +54,7 @@ if (a != null ? a.length : void 0) { | ||
}; | ||
escapeRegExp = function(str) { | ||
return str.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); | ||
}; | ||
create = function(config) { | ||
@@ -67,3 +79,3 @@ var corsHandler; | ||
resourceHandler = function(obj, i) { | ||
var headers, matchOrigin, methods, origins, pattern; | ||
var credentials, headers, matchOrigin, methods, origins, pattern; | ||
pattern = obj.pattern; | ||
@@ -73,2 +85,3 @@ methods = selectNotEmpty(obj.methods, config.methods); | ||
origins = selectNotEmpty(obj.origins, config.origins) || defaultOrigins; | ||
credentials = selectNotEmpty(obj.credentials, config.credentials); | ||
origin = req.headers.origin; | ||
@@ -109,3 +122,3 @@ matchOrigin = function(originPattern, i) { | ||
} | ||
if (typeof credentials !== "undefined" && credentials !== null) { | ||
if (credentials != null) { | ||
res.setHeader('Access-Control-Allow-Credentials', "true"); | ||
@@ -135,3 +148,5 @@ } | ||
}; | ||
module.exports = create; | ||
}).call(this); |
@@ -8,3 +8,3 @@ { | ||
"description": "CORS / XHR2 support for Node.JS's Connect", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"homepage": "https://github.com/antono/connect-cors", | ||
@@ -11,0 +11,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
31792
383
0
3