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

@neoskop/aviation-client

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoskop/aviation-client - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

7

dist/model/aviation-feature.js

@@ -41,8 +41,11 @@ "use strict";

if (this._functionEnabled) {
var hostname = void 0;
var hostname = '';
var preview = false;
if (request) {
hostname = request.headers.host;
hostname = request.headers['host'];
preview = request.headers['x-aviation-preview'] && request.headers['x-aviation-preview'] == 'true';
}
else if (typeof window != 'undefined') {
hostname = window.location.hostname;
preview = window.localStorage.getItem('aviationPreview') && window.localStorage.getItem('aviationPreview') == 'true';
}

@@ -49,0 +52,0 @@ var returnValue = eval('(function(){' + this._functionCode + '})()');

@@ -6,4 +6,12 @@ "use strict";

var httpMocks = require("node-mocks-http");
var jsdom = require("jsdom");
var dom = new jsdom.JSDOM('');
before(function () {
chai.should();
global['document'] = dom;
global['window'] = dom.window;
var nodeLocalStorage = require('node-localstorage');
var LocalStorage = nodeLocalStorage.LocalStorage;
global['localStorage'] = new LocalStorage('./tmp');
global['window'].localStorage = global['localStorage'];
});

@@ -71,3 +79,41 @@ describe('Aviation feature', function () {

});
it('should allow the function to check the hostname in browser context', function () {
var sut = new aviation_feature_1.AviationFeature({
name: 'foo',
enabled: false,
functionCode: 'return hostname == "foo"',
functionEnabled: true
});
dom.reconfigure({ url: "https://foo/bar" });
return sut.evaluate().should.be.true;
});
it('should should be testable in node.js contexts', function () {
var sut = new aviation_feature_1.AviationFeature({
name: 'foo',
enabled: false,
functionCode: 'return preview',
functionEnabled: true
});
var req = httpMocks.createRequest({
url: 'https://foo',
headers: {
Host: 'foo',
'X-Aviation-Preview': 'true'
}
});
return sut.evaluate(req).should.be.true;
});
it('should should be testable in browser contexts', function () {
var sut = new aviation_feature_1.AviationFeature({
name: 'foo',
enabled: false,
functionCode: 'return preview',
functionEnabled: true
});
window.localStorage.setItem('aviationPreview', 'true');
var result = sut.evaluate().should.be.true;
window.localStorage.removeItem('aviationPreview');
return result;
});
});
//# sourceMappingURL=aviation-feature.spec.js.map
{
"name": "@neoskop/aviation-client",
"version": "0.2.0",
"version": "0.2.1",
"main": "dist/index.js",

@@ -22,3 +22,3 @@ "typings": "dist/index.d.ts",

"devDependencies": {
"@types/chai": "^4.0.0",
"@types/chai": "^4.0.1",
"@types/chai-as-promised": "^0.0.31",

@@ -37,4 +37,4 @@ "@types/express": "^4.0.36",

"ts-node": "^3.0.6",
"typescript": "^2.3.4"
"typescript": "^2.4.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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