Comparing version 0.0.11 to 0.0.12
26
index.js
@@ -12,4 +12,2 @@ /** | ||
origin: function(req) { | ||
// http://www.w3.org/TR/cors/#supports-credentials | ||
// #3 "The string "*" cannot be used for a resource that supports credentials." | ||
return req.header.origin || '*'; | ||
@@ -20,14 +18,10 @@ }, | ||
settings = settings || defaults; | ||
return function* cors(next) { | ||
var options = { | ||
origin: settings.origin || defaults.origin, | ||
methods: settings.methods || defaults.methods, | ||
credentials: settings.credentials, | ||
headers: settings.headers, | ||
expose: settings.expose, | ||
maxAge: settings.maxAge | ||
}; | ||
/** | ||
* Set options | ||
* | ||
* @type {Object} | ||
*/ | ||
var options = settings || defaults; | ||
@@ -43,4 +37,4 @@ if (typeof options.origin === 'function') { | ||
return; | ||
} else if (!options.origin || options.origin === true) { | ||
options.origin = defaults.origin; | ||
} else if (typeof options.origin === 'undefined' || options.origin === true) { | ||
options.origin = defaults.origin(this.request); | ||
} | ||
@@ -79,3 +73,5 @@ this.set('Access-Control-Allow-Origin', options.origin); | ||
*/ | ||
if (options.methods.join) { | ||
if (typeof options.methods === 'undefined') { | ||
options.methods = defaults.methods; | ||
} else if (options.methods.join) { | ||
options.methods = options.methods.join(','); | ||
@@ -82,0 +78,0 @@ } |
{ | ||
"name": "koa-cors", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "CORS middleware for Koa", | ||
@@ -23,3 +23,9 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/evert0n/koa-cors" | ||
"homepage": "https://github.com/evert0n/koa-cors", | ||
"devDependencies": { | ||
"koa": "^0.6.1", | ||
"chai": "^1.9.1", | ||
"mocha": "^1.19.0", | ||
"superagent": "^0.18.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12679
9
284
4
1