Comparing version 0.0.12 to 0.0.13
17
index.js
@@ -26,15 +26,14 @@ /** | ||
if (typeof options.origin === 'function') { | ||
options.origin = options.origin(this.request); | ||
} | ||
/** | ||
* Access Control Allow Origin | ||
*/ | ||
if (options.origin === false) { | ||
return; | ||
} else if (typeof options.origin === 'undefined' || options.origin === true) { | ||
options.origin = defaults.origin(this.request); | ||
if (options.origin === false) return; | ||
var origin; | ||
if (typeof options.origin === 'string') { | ||
origin = options.origin; | ||
} else { | ||
origin = defaults.origin(this.request); | ||
} | ||
this.set('Access-Control-Allow-Origin', options.origin); | ||
this.set('Access-Control-Allow-Origin', origin); | ||
@@ -41,0 +40,0 @@ /** |
{ | ||
"name": "koa-cors", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "CORS middleware for Koa", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -54,7 +54,3 @@ koa-cors | ||
## Todo | ||
- Unit tests | ||
- Live demo | ||
## License | ||
@@ -61,0 +57,0 @@ |
@@ -34,2 +34,17 @@ var koa = require('koa'); | ||
it('should update "Access-Control-Allow-Origin" for each request', function(done) { | ||
superagent.get('http://localhost:3000') | ||
.end(function(response) { | ||
chai.expect(response.get('Access-Control-Allow-Origin')).to.equal('*'); | ||
superagent.get('http://localhost:3000') | ||
.set('Origin', 'localhost') | ||
.end(function(response) { | ||
chai.expect(response.get('Access-Control-Allow-Origin')).to.equal('localhost'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should not set "Access-Control-Expose-Headers"', function(done) { | ||
@@ -36,0 +51,0 @@ superagent.get('http://localhost:3000') |
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
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
13046
295
62