mastercontroller 1.1.12 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/MasterControl.js CHANGED
File without changes
package/MasterCors.js CHANGED
@@ -1,4 +1,4 @@
1
- // version 1.1.6
1
+ // version 1.1.7
2
2
  var master = require('./MasterControl');
3
3
  var tools = require('./MasterTools');
4
4
 
@@ -41,27 +41,23 @@ class MasterCors{
41
41
  configureOrigin(){
42
42
  // this will set the origin based on the the options value
43
43
  if(this.options.origin){
44
- var originBool = JSON.parse(this.options.origin);
45
- if(originBool === true){
44
+
45
+ if(typeof this.options.origin === 'string'){
46
+ this.setHeader('access-control-allow-origin', this.options.origin);
47
+ }
48
+
49
+ if(this.options.origin === true){
46
50
  this.setHeader('access-control-allow-origin', '*');
47
51
  }
48
52
 
49
53
  // remove all origins
50
- if(originBool === false){
54
+ if(this.options.origin === false){
51
55
  this.removeHeader('access-control-allow-origin');
52
56
  }
53
-
54
- if(typeof this.options.origin === 'string'){
55
- this.setHeader('access-control-allow-arigin', this.options.origin);
56
- }
57
57
 
58
- if(this.options.origin.constructor === Array){
59
- // loop through list of array and set the once thatis found from the request because you can only setone at a time
60
- var requestURL = this.request.url;
58
+ if(this.options.origin.constructor === Array){
61
59
  for (const element of this.options.origin) {
62
- if(element === requestURL){
63
- this.setHeader('access-control-allow-arigin', element);
64
- }
60
+ this.setHeader('access-control-allow-origin', element);
65
61
  }
66
62
 
67
63
  }
@@ -82,21 +78,20 @@ class MasterCors{
82
78
  var requestheader = this.request.headers["access-control-request-headers"];
83
79
  var $that = this;
84
80
  if(this.options.allowedHeaders){
85
- var allowedBool = JSON.parse($that.options.allowedHeaders);
86
- if(allowedBool === true){
87
- // get Access-Control-Request-Headers
88
81
 
82
+ if($that.options.allowedHeaders === true){
83
+ // get Access-Control-Request-Headers
89
84
  $that.request.headers['access-control-allow-headers'] = requestheader;
90
85
  this.setHeader("access-control-allow-headers", "*");
91
86
  }
92
87
 
93
88
  // remove all headers
94
- if(allowedBool === false){
89
+ if($that.options.allowedHeaders === false){
95
90
  delete $that.request.headers['access-control-allow-headers'];
96
91
  this.removeHeader("access-control-allow-headers", "*");
97
92
  }
98
93
 
99
- if($that.options.allowedHeaders === 'string'){
94
+ if(typeof $that.options.allowedHeaders === 'string'){
100
95
  $that.request.headers['access-control-allow-headers'] = $that.options.allowedHeaders;
101
96
  this.setHeader("access-control-allow-headers", $that.options.allowedHeaders);
102
97
  }
@@ -114,13 +109,13 @@ class MasterCors{
114
109
  //exposeHeaders
115
110
  //Access-Control-Expose-Headers
116
111
  if(this.options.exposeHeaders){
117
- var allowedBool = JSON.parse(this.options.exposeHeaders);
112
+
118
113
  // remove all headers
119
- if(allowedBool === false){
114
+ if(this.options.exposeHeaders === false){
120
115
  this.removeHeader('access-control-expose-headers');
121
116
  }
122
117
 
123
- if(this.options.exposeHeaders === 'string'){
118
+ if(typeof this.options.exposeHeaders === 'string'){
124
119
  this.setHeader('access-control-expose-headers', this.options.exposeHeaders);
125
120
  }
126
121
 
@@ -134,18 +129,16 @@ class MasterCors{
134
129
 
135
130
  configureCredentials(){
136
131
  if(this.options.credentials){
137
- var credentialsBool = JSON.parse(this.options.credentials);
138
- if(typeof credentialsBool === "boolean"){
139
- this.setHeader('access-control-allow-credentials', credentialsBool);
132
+ if(typeof this.options.credentials === "boolean"){
133
+ this.setHeader('access-control-allow-credentials', this.options.credentials);
140
134
  }
141
135
  }
142
136
  }
143
137
 
144
138
  configureMaxAge(){
145
139
  if(this.options.maxAge){
146
- var maxAgeNumber = parseInt(this.options.maxAge);
147
- if(typeof maxAgeNumber === "number"){
148
- this.setHeader('access-control-allow-max-age', maxAgeNumber);
140
+ if(typeof this.options.maxAge === "number"){
141
+ this.setHeader('access-control-allow-max-age', this.options.maxAge);
149
142
  }
150
143
  }
151
144
  }
package/package.json CHANGED
@@ -1,42 +1,10 @@
1
1
  {
2
- "_from": "mastercontroller@1.1.12",
3
- "_id": "mastercontroller@1.1.12",
4
- "_inBundle": false,
5
- "_integrity": "sha512-dqqGXFn65iMzgGFKut8M5AuZ36Nm9UgJkqkuc8kr+/ESWKLAyMjEp0BOYhyupMplJ+8iSDmQ7BlIHyL4gaGr1A==",
6
- "_location": "/mastercontroller",
7
- "_phantomChildren": {},
8
- "_requested": {
9
- "type": "version",
10
- "registry": true,
11
- "raw": "mastercontroller@1.1.12",
12
- "name": "mastercontroller",
13
- "escapedName": "mastercontroller",
14
- "rawSpec": "1.1.12",
15
- "saveSpec": null,
16
- "fetchSpec": "1.1.12"
17
- },
18
- "_requiredBy": [
19
- "#USER",
20
- "/"
21
- ],
22
- "_resolved": "https://registry.npmjs.org/mastercontroller/-/mastercontroller-1.1.12.tgz",
23
- "_shasum": "30bdeec92ece92441caca1659fe238ea78991e7c",
24
- "_spec": "mastercontroller@1.1.12",
25
- "_where": "C:\\Users\\rbatista\\Downloads\\kollege\\freshmen",
26
- "author": {
27
- "name": "Alexander Rich"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/Tailor/MasterController/issues"
31
- },
32
- "bundleDependencies": [],
33
2
  "dependencies": {
34
- "qs" : "^6.10.1",
35
- "formidable": "^1.2.2",
36
- "cookie": "^0.4.1",
37
- "winston": "^3.3.3"
3
+ "qs" : "^6.11.0",
4
+ "formidable": "^2.0.1",
5
+ "cookie": "^0.5.0",
6
+ "winston": "^3.8.2"
38
7
  },
39
- "deprecated": false,
40
8
  "description": "A class library that makes using the Master Framework a breeze",
41
9
  "homepage": "https://github.com/Tailor/MasterController#readme",
42
10
  "license": "ISC",
@@ -49,5 +17,5 @@
49
17
  "scripts": {
50
18
  "test": "echo \"Error: no test specified\" && exit 1"
51
19
  },
52
- "version": "1.1.12"
20
+ "version": "1.1.14"
53
21
  }