From 66de38c2462b336f9f4f0d0d46a86a758a93d744 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 9 Jun 2021 17:20:52 -0500 Subject: [PATCH] fix(ident): quote if there are capital letters fix #22 --- index.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/index.js b/index.js index 4c66afa..636b0fb 100644 --- a/index.js +++ b/index.js @@ -105,7 +105,7 @@ exports.dollarQuotedString = function(val) { exports.ident = function(val){ assert(null != val, 'identifier required'); - return validIdent(val) ? val : quoteIdent(val); + return reserved[val] || /^[a-z_][a-z0-9_$]*$/.test(val) ? quoteIdent(val) : val; }; /** @@ -129,19 +129,6 @@ exports.literal = function(val){ return prefix + "'" + val + "'"; }; -/** - * Check if `id` is a valid unquoted identifier. - * - * @param {String} id - * @return {Boolean} - * @api private - */ - -function validIdent(id) { - if (reserved[id]) return false; - return /^[a-z_][a-z0-9_$]*$/i.test(id); -} - /** * Quote identifier. *