Skip to content

Commit 4e38dba

Browse files
author
Eran Hammer
committed
cleanup for $2418
1 parent d283f45 commit 4e38dba

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internals.Methods.prototype.add = function (name, method, options, realm) {
3535
};
3636

3737

38-
exports.methodNameRx = /^[_$a-zA-Z]\w*(?:\.[_$a-zA-Z]\w*)*$/;
38+
exports.methodNameRx = /^[_$a-zA-Z][$\w]*(?:\.[_$a-zA-Z][$\w]*)*$/;
3939

4040

4141
internals.Methods.prototype._add = function (name, method, options, realm) {

test/methods.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,40 @@ describe('Methods', function () {
7373
});
7474
});
7575

76+
it('registers a method with _', function (done) {
77+
78+
var _add = function (a, b, next) {
79+
80+
return next(null, a + b);
81+
};
82+
83+
var server = new Hapi.Server();
84+
server.method('add_._that', _add);
85+
86+
server.methods.add_._that(1, 5, function (err, result) {
87+
88+
expect(result).to.equal(6);
89+
done();
90+
});
91+
});
92+
93+
it('registers a method with $', function (done) {
94+
95+
var $add = function (a, b, next) {
96+
97+
return next(null, a + b);
98+
};
99+
100+
var server = new Hapi.Server();
101+
server.method('add$.$that', $add);
102+
103+
server.methods.add$.$that(1, 5, function (err, result) {
104+
105+
expect(result).to.equal(6);
106+
done();
107+
});
108+
});
109+
76110
it('registers a method (no callback)', function (done) {
77111

78112
var add = function (a, b) {

0 commit comments

Comments
 (0)