Yuki Takei 7 лет назад
Родитель
Сommit
5a593b95c7

+ 1 - 1
packages/growi-commons/package.json

@@ -1,6 +1,6 @@
 {
   "name": "growi-commons",
-  "version": "3.2.3",
+  "version": "3.2.4",
   "description": "GROWI Commons Libraries",
   "keywords": [
     "growi"

+ 5 - 0
packages/growi-commons/src/plugin/util/args-parser.js

@@ -21,6 +21,11 @@ class ArgsParser {
         // parse string like 'key1=value1, key2=value2, ...'
         // see https://regex101.com/r/pYHcOM/1
         const match = arg.match(/([^=]+)=?(.+)?/);
+
+        if (match == null) {
+          return;
+        }
+
         const key = match[1];
         const value = match[2] || true;
         options[key] = value;

+ 10 - 0
packages/growi-commons/src/test/plugin/util/args-parser.test.js

@@ -31,4 +31,14 @@ describe('args-parser', () => {
     expect(result.options.opt2).toBe('2');
   });
 
+  test('.parse(\'key, \') returns a valid results', () => {
+    const result = ArgsParser.parse('key, ');
+
+    expect(result.firstArgsKey).toBe('key');
+    expect(result.firstArgsValue).toBeTruthy();
+
+    expect(Object.keys(result.options).length).toBe(1);
+    expect(result.options.key).toBeTruthy();
+  });
+
 });