2
0
Lutz Roeder 3 жил өмнө
parent
commit
13d208e556
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      tools/protoc.js

+ 2 - 2
tools/protoc.js

@@ -320,7 +320,7 @@ protoc.Field = class extends protoc.Object {
         if (!Number.isInteger(id) || id < 0) {
             throw new protoc.Error('Identifier must be a non-negative integer.');
         }
-        if (rule && !/^required|optional|repeated$/.test(rule = rule.toString().toLowerCase())) {
+        if (rule && rule !== 'required' && rule !== 'optional' && rule !== 'repeated') {
             throw new protoc.Error('Rule must be a string.');
         }
         this.id = id;
@@ -763,7 +763,7 @@ protoc.Parser = class {
                     this._parseField(parent, token, reference);
                     break;
                 default:
-                    if (!this._syntax !== 'proto3' || !protoc.Parser._isTypeReference(token)) {
+                    if (this._syntax === 'proto3' || !protoc.Parser._isTypeReference(token)) {
                         throw this._parseError(token);
                     }
                     this._tokenizer.push(token);