Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/loadServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import csrf from 'csurf';
import SaplingError from '../lib/SaplingError.js';
import Response from '../lib/Response.js';
import Cluster from '../lib/Cluster.js';
import Utils from '../lib/Utils.js';


/**
Expand Down Expand Up @@ -73,9 +74,7 @@ export default function loadServer({ reload, listen }, next) {
/* Handle the directory for our static resources */
if ('publicDir' in this.config) {
/* If it's a string, coerce into an array */
if (Array.isArray(this.config.publicDir) === false) {
this.config.publicDir = [this.config.publicDir];
}
this.config.publicDir = new Utils().coerceArray(this.config.publicDir);

/* Loop through it */
for (const publicDir of this.config.publicDir) {
Expand Down
7 changes: 1 addition & 6 deletions drivers/db/Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,7 @@ export default class Memory extends Interface {
continue;
}

let condition = conditions[field];

/* Coerce into an array */
if (Array.isArray(condition) === false) {
condition = [condition];
}
const condition = new Utils().coerceArray(conditions[field]);

match = condition.some(value => {
/* If it's an ID, do an exact match always */
Expand Down
5 changes: 2 additions & 3 deletions lib/Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import isobject from 'isobject';
import { console } from './Cluster.js';
import Redirect from './Redirect.js';
import Templating from './Templating.js';
import Utils from './Utils.js';


/**
Expand Down Expand Up @@ -70,9 +71,7 @@ export default class Response {
}

/* Coerce anything else into an array */
if (!Array.isArray(array)) {
array = [array];
}
array = new Utils().coerceArray(array);

/* Whether the array contains objects or something else */
const notObject = array.length > 0 && !isobject(array[0]);
Expand Down
3 changes: 2 additions & 1 deletion lib/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import routeMatcher from 'path-match';

import Response from './Response.js';
import SaplingError from './SaplingError.js';
import Utils from './Utils.js';


/**
Expand Down Expand Up @@ -148,7 +149,7 @@ export default class User {
const userType = permissionKey in this.app.permissions ? this.app.permissions[permissionKey].role : 'anyone';

/* Return the first match */
return Array.isArray(userType) ? userType : [userType];
return new Utils().coerceArray(userType);
}
}

Expand Down