-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
45 lines (34 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* jshint node: true */
'use strict';
var path = require('path');
module.exports = {
name: 'ember-solr',
_appendPolicy: function(csp, key, value) {
var v = csp[key] || '';
if (v) {
v += ' ';
}
csp[key] = v + value;
},
config: function(environment, appConfig) {
if (!appConfig.solrBaseURL || appConfig.solrBaseURL.indexOf(':') === -1) {
return;
}
var solrSchemeAndHost = appConfig.solrBaseURL;
var solrHostEnd = solrSchemeAndHost.indexOf('/', solrSchemeAndHost.indexOf('://') + 3);
if (solrHostEnd > 0) {
solrSchemeAndHost = solrSchemeAndHost.substring(0, solrHostEnd);
}
var csp = appConfig.contentSecurityPolicy || {};
this._appendPolicy(csp, 'connect-src', solrSchemeAndHost);
this._appendPolicy(csp, 'script-src', solrSchemeAndHost);
var ENV = {
contentSecurityPolicy: csp
};
return ENV;
},
included: function json_bignum_included(app) {
this._super.included(app);
app.import(path.join(app.bowerDirectory, 'json-bignum', 'lib', 'json-bignum.js'));
}
};