Skip to content

Commit 88a6788

Browse files
committed
Check if the delimiter contains a single character
1 parent 3c4e5e7 commit 88a6788

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Configuration keys supported only by the data-table plugin:
2121
| :-- | :-- | :-- | :-- |
2222
| `entityType` | "edge" \| "node" (**required**) | Whether to display nodes or edges in the table. | `"node"` |
2323
| `itemType` | string (**required**) | Name of the node category or edge type to display in the table. | `"Company"` |
24-
| `delimiter` | string (**optional**) | The delimiter used for csv files downloads. By default "," is used | `";"` |
24+
| `delimiter` | string (**optional**) | The delimiter used for csv files downloads. Only one character is allowed. By default "," is used | `";"` |
2525
| `properties` | string\[] (**optional**) | Property names to include in the table. Defaults to all the properties of `itemType`. | `["name", "address", "vat_number"]` |
2626

2727
Configuration example for 1 data-table instance accesible via `/plugins/table`:

backend/routeHandler.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ module.exports = function configureRoutes(options) {
2626
* @param entityType
2727
* @param itemType
2828
* @param properties
29+
* @param delimiter
2930
* @returns {{message: string}|{message: string}|{message: string}|null|{message: string}}
3031
*/
31-
function checkPluginsConfiguration(schemaTypes, entityType, itemType, properties) {
32+
function checkPluginsConfiguration(schemaTypes, entityType, itemType, properties, delimiter) {
3233
if (entityType && entityType !== 'node' && entityType !== 'edge') {
3334
return {message: 'Invalid plugin configuration “entityType” (must be “node” or “edge”)'};
3435
}
@@ -40,6 +41,9 @@ module.exports = function configureRoutes(options) {
4041
if (properties && (!Array.isArray(properties) || properties.length === 0)) {
4142
return {message: 'Invalid plugin configuration “properties” (must be a non-empty array of property names)'};
4243
}
44+
if (delimiter && delimiter.length != 1) {
45+
return {message: 'Invalid plugin configuration “delimiter” (only one character is allowed)'};
46+
}
4347
return null;
4448
}
4549

@@ -48,7 +52,8 @@ module.exports = function configureRoutes(options) {
4852
const entityType = options.configuration.entityType;
4953
const itemType = options.configuration.itemType;
5054
const properties = options.configuration.properties;
51-
const error = checkPluginsConfiguration(schemaTypes, entityType, itemType, properties);
55+
const delimiter = options.configuration.delimiter;
56+
const error = checkPluginsConfiguration(schemaTypes, entityType, itemType, properties, delimiter);
5257
if (error) {
5358
res.status(412);
5459
res.send(JSON.stringify({status: 412, body: {error}}));

0 commit comments

Comments
 (0)