From 62297998d681357ada70fb370b99bac5573e5054 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Mon, 27 Nov 2017 17:36:56 +0100 Subject: [PATCH] Fixed: Prevent parse errors when generating service method names, see #870 --- src/service.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service.js b/src/service.js index c60b3604b..cc419f6a7 100644 --- a/src/service.js +++ b/src/service.js @@ -152,7 +152,8 @@ Service.prototype.remove = function remove(object) { Service.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) { var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited); for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) { - rpcService[util.lcFirst((method = this._methodsArray[i]).resolve().name)] = util.codegen(["r","c"], util.lcFirst(method.name))("return this.rpcCall(m,q,s,r,c)")({ + var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, ""); + rpcService[methodName] = util.codegen(["r","c"], util.isReserved(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({ m: method, q: method.resolvedRequestType.ctor, s: method.resolvedResponseType.ctor