1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-10 22:23:36 +02:00

Make use of String#trim.

--HG--
extra : rebase_source : d55aa303e47dab2902c8fdfafb9e82f603ff0c67
This commit is contained in:
Doug Kearns
2010-09-23 00:33:54 +10:00
parent 6df344ed91
commit 31e3544006

View File

@@ -336,10 +336,10 @@ const Dactyl = Module("dactyl", {
// Better name? See other dactyl.usereval() // Better name? See other dactyl.usereval()
// I agree, the name is confusing, and so is the // I agree, the name is confusing, and so is the
// description --Kris // description --Kris
evalExpression: function (string) { evalExpression: function (str) {
string = string.toString().replace(/^\s*/, "").replace(/\s*$/, ""); str = str.trim(); // XXX
let matches = string.match(/^&(\w+)/); let matches = str.match(/^&(\w+)/);
if (matches) { if (matches) {
let opt = this.options.get(matches[1]); let opt = this.options.get(matches[1]);
@@ -354,17 +354,17 @@ const Dactyl = Module("dactyl", {
return value; return value;
} }
// String // String
else if ((matches = string.match(/^(['"])([^\1]*?[^\\]?)\1/))) { else if ((matches = str.match(/^(['"])([^\1]*?[^\\]?)\1/))) {
return matches[2].toString(); return matches[2].toString();
} }
// Number // Number
else if ((matches = string.match(/^(\d+)$/))) else if ((matches = str.match(/^(\d+)$/)))
return parseInt(matches[1], 10); return parseInt(matches[1], 10);
let reference = this.variableReference(string); let reference = this.variableReference(str);
if (!reference[0]) if (!reference[0])
this.echoerr("E121: Undefined variable: " + string); this.echoerr("E121: Undefined variable: " + str);
else else
return reference[0][reference[1]]; return reference[0][reference[1]];
return null; return null;
@@ -962,7 +962,7 @@ const Dactyl = Module("dactyl", {
} }
// strip each 'URL' - makes things simpler later on // strip each 'URL' - makes things simpler later on
url = url.replace(/^\s+|\s+$/, ""); url = url.trim();
// Look for a valid protocol // Look for a valid protocol
let proto = url.match(/^([-\w]+):/); let proto = url.match(/^([-\w]+):/);