Socket
Socket
Sign inDemoInstall

ember-fastboot-server

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-fastboot-server - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

3

lib/ember-app.js

@@ -8,3 +8,3 @@ var fs = require('fs');

var FastBootInfo = require('./fastboot-info');
var Sandbox = require('./sandbox');
var VMSandbox = require('./sandboxes/vm');

@@ -30,2 +30,3 @@ var HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap);

var sandboxRequire = buildWhitelistedRequire(moduleWhitelist, distPath);
var Sandbox = options.sandbox || VMSandbox;
var sandbox = new Sandbox({

@@ -32,0 +33,0 @@ globals: {

// Partially implements Headers from the Fetch API
// https://developer.mozilla.org/en-US/docs/Web/API/Headers
function FastBootHeaders(headers) {
this.headers = headers
headers = headers || {};
this.headers = {};
for (var header in headers) {
this.headers[header] = headers[header].split(', ');
};
}
FastBootHeaders.prototype.append = function(header, value) {
header = header.toLowerCase();
if (!this.has(header)) {
this.headers[header] = [];
}
this.headers[header].push(value);
}
FastBootHeaders.prototype.delete = function(header) {
delete this.headers[header.toLowerCase()];
}
FastBootHeaders.prototype.entries = function() {
var entries = [];
for(var key in this.headers) {
var values = this.headers[key];
for(var index = 0; index < values.length; ++index ) {
entries.push([key, values[index]]);
}
}
return entries[Symbol.iterator]();
}
FastBootHeaders.prototype.get = function(header) {

@@ -12,15 +43,40 @@ return this.getAll(header)[0] || null;

FastBootHeaders.prototype.getAll = function(header) {
var headerValue = this.headers[header.toLowerCase()];
return this.headers[header.toLowerCase()] || [];
}
if (headerValue) {
return headerValue.split(', ');
FastBootHeaders.prototype.has = function(header) {
return this.headers[header.toLowerCase()] !== undefined;
}
FastBootHeaders.prototype.keys = function() {
var entries = [];
for(var key in this.headers) {
var values = this.headers[key];
for(var index = 0; index < values.length; ++index ) {
entries.push(key);
}
}
return [];
return entries[Symbol.iterator]();
}
FastBootHeaders.prototype.has = function(header) {
return this.headers[header.toLowerCase()] !== undefined;
FastBootHeaders.prototype.set = function(header, value) {
header = header.toLowerCase();
this.headers[header] = [value];
}
FastBootHeaders.prototype.values = function() {
var entries = [];
for(var key in this.headers) {
var values = this.headers[key];
for(var index = 0; index < values.length; ++index ) {
entries.push(values[index]);
}
}
return entries[Symbol.iterator]();
}
module.exports = FastBootHeaders;
var chalk = require('chalk');
function isLegacyVM() {
return require('vm').isContext === undefined;
function Sandbox() {
}
function Sandbox(options) {
var klass;
if (isLegacyVM()) {
klass = require('./sandboxes/contextify');
} else {
klass = require('./sandboxes/vm');
}
return new klass(options);
}
Sandbox.prototype.init = function(options) {

@@ -63,4 +50,2 @@ this.globals = options.globals;

Sandbox.isLegacyVM = isLegacyVM;
module.exports = Sandbox;
{
"name": "ember-fastboot-server",
"version": "0.6.2",
"version": "0.7.0",
"description": "Production server for running Ember applications using FastBoot",
"main": "./lib/server",
"scripts": {
"postinstall": "scripts/is-not-legacy-vm || npm install contextify@^0.1.11",
"test": "mocha"

@@ -9,0 +8,0 @@ },

@@ -54,3 +54,3 @@ var expect = require('chai').expect;

it('returns whether or not a header is present via has, regardless of case', function() {
it('returns whether or not a header is present via has, regardless of casing', function() {
var headers = {

@@ -68,3 +68,84 @@ // Express concatenates repeated keys with ', '

});
it('appends entries onto a header, regardless of casing', function() {
var headers = new FastBootHeaders();
expect(headers.has('x-foo')).to.be.false;
headers.append('X-Foo', 'bar');
expect(headers.has('x-foo')).to.be.true;
expect(headers.getAll('x-foo')).to.deep.equal(['bar']);
headers.append('X-Foo', 'baz');
expect(headers.getAll('x-foo')).to.deep.equal(['bar', 'baz']);
});
it('deletes entries onto a header, regardless of casing', function() {
var headers = new FastBootHeaders();
headers.append('X-Foo', 'bar');
expect(headers.has('x-foo')).to.be.true;
headers.delete('X-Foo');
expect(headers.has('x-foo')).to.be.false;
});
it('returns an iterator for the header/value pairs when calling entries', function() {
var headers = new FastBootHeaders();
headers.append('X-Foo', 'foo');
headers.append('X-Foo', 'baz');
headers.append('x-bar', 'bar');
var entriesIterator = headers.entries();
expect(entriesIterator.next()).to.deep.equal({ value: ['x-foo', 'foo'], done: false });
expect(entriesIterator.next()).to.deep.equal({ value: ['x-foo', 'baz'], done: false });
expect(entriesIterator.next()).to.deep.equal({ value: ['x-bar', 'bar'], done: false });
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});
it('returns an iterator for keys containing all the keys', function() {
var headers = new FastBootHeaders();
headers.append('X-Foo', 'foo');
headers.append('X-Foo', 'baz');
headers.append('x-bar', 'bar');
var entriesIterator = headers.keys();
expect(entriesIterator.next()).to.deep.equal({ value: 'x-foo', done: false });
expect(entriesIterator.next()).to.deep.equal({ value: 'x-foo', done: false });
expect(entriesIterator.next()).to.deep.equal({ value: 'x-bar', done: false });
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});
it('sets a header, overwriting existing values, regardless of casing', function() {
var headers = new FastBootHeaders();
expect(headers.getAll('x-foo')).to.deep.equal([]);
expect(headers.getAll('x-bar')).to.deep.equal([]);
headers.append('X-Foo', 'foo');
expect(headers.getAll('x-foo')).to.deep.equal(['foo']);
headers.set('x-foo', 'bar');
expect(headers.getAll('X-foo')).to.deep.equal(['bar']);
headers.set('X-Bar', 'baz');
expect(headers.getAll('x-bar')).to.deep.equal(['baz']);
});
it('returns an iterator for values containing all the values', function() {
var headers = new FastBootHeaders();
headers.append('X-Foo', 'foo');
headers.append('X-Foo', 'baz');
headers.append('x-bar', 'bar');
var entriesIterator = headers.values();
expect(entriesIterator.next()).to.deep.equal({ value: 'foo', done: false });
expect(entriesIterator.next()).to.deep.equal({ value: 'baz', done: false });
expect(entriesIterator.next()).to.deep.equal({ value: 'bar', done: false });
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});
});
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