Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-cors

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-cors - npm Package Compare versions

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')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc