From 9b7b92a4c7f8caa460d687778dc0628a74cdde37 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Thu, 15 Dec 2016 14:49:41 +0100 Subject: [PATCH] Fixed reserved names re, also ensure valid service method names, see #559 --- cli/targets/static.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/targets/static.js b/cli/targets/static.js index f5edfd69b..2ee30ce38 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -74,7 +74,7 @@ function pushComment(lines) { push(" */"); } -var reservedRe = /^do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof$/; +var reservedRe = /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/; function name(name) { if (!name) @@ -402,7 +402,7 @@ function buildService(ref, service) { "@param {function(?Error, " + method.resolvedResponseType.fullName.substring(1) + "=)} callback Node-style callback called with the error, if any, and " + method.resolvedResponseType.name, "@returns {undefined}" ]); - push(name(service.name) + ".prototype." + name(lcName) + " = function " + name(lcName) + "(request, callback) {"); + push(name(service.name) + ".prototype[" + JSON.stringify(lcName) + "] = function " + name(lcName) + "(request, callback) {"); ++indent; push("var requestData;"); push("try {");