Skip to content

Ensure synthetic function names conform to naming requirements #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ensure synthetic function names conform to naming requirements
The "restore-asking" function name is not valid and was causing co-redis (by way of its usage of thenify) to throw because thenify uses the function name to rewrite async functions with promises.

This PR will change the name of the "restore-asking" function to "restore_asking", which is valid.

This sanitation is a bit stricter than necessary, since it also sanitizes valid unicode characters, but it covers this module's potential use cases just fine.
  • Loading branch information
danmactough committed Jun 1, 2016
commit 68ca5c760b4bd6f46201820277e3720b975d55c1
5 changes: 3 additions & 2 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var changeFunctionName = (function () {
// that provided a functionality to add new commands to the client

commands.list.forEach(function (command) {
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');

// Do not override existing functions
if (!RedisClient.prototype[command]) {
Expand Down Expand Up @@ -59,7 +60,7 @@ commands.list.forEach(function (command) {
};
if (changeFunctionName) {
Object.defineProperty(RedisClient.prototype[command], 'name', {
value: command
value: commandName
});
}
}
Expand Down Expand Up @@ -102,7 +103,7 @@ commands.list.forEach(function (command) {
};
if (changeFunctionName) {
Object.defineProperty(Multi.prototype[command], 'name', {
value: command
value: commandName
});
}
}
Expand Down