diff --git a/src/base.js b/src/base.js index 6120c41..eae7f18 100644 --- a/src/base.js +++ b/src/base.js @@ -159,7 +159,7 @@ Object.extend(Object, { Object.extend(Function.prototype, { argumentNames: function() { - var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(/\s*,\s*/); + var names = this.toString().match(/^[\s\(]*function[^(]*\(\s*(.*?)\s*\)/)[1].split(/\s*,\s*/); return names.length == 1 && !names[0] ? [] : names; }, diff --git a/test/unit/base_test.js b/test/unit/base_test.js index 8b6a466..73e268f 100644 --- a/test/unit/base_test.js +++ b/test/unit/base_test.js @@ -3,6 +3,7 @@ new Test.Unit.Runner({ this.assertEnumEqual([], (function() {}).argumentNames()); this.assertEnumEqual(["one"], (function(one) {}).argumentNames()); this.assertEnumEqual(["one", "two", "three"], (function(one, two, three) {}).argumentNames()); + this.assertEnumEqual(["one", "two", "three"], (function( one , two , three ) {}).argumentNames()); this.assertEqual("$super", (function($super) {}).argumentNames().first()); function named1() {};