Skip to content

Commit

Permalink
fix(ident): quote if there are capital letters
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Jun 9, 2021
1 parent 780350b commit 66de38c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand All @@ -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.
*
Expand Down

0 comments on commit 66de38c

Please sign in to comment.