Permalink
Browse files

Updating parser.

  • Loading branch information...
1 parent 8c801bc commit c43a8105b8b7259c38c9c6308b8ffcd013a6d662 Andre Rodrigues committed Oct 10, 2012
Showing with 12 additions and 13 deletions.
  1. +12 −13 lib/services/core/connectionstringparser.js
View
25 lib/services/core/connectionstringparser.js
@@ -16,7 +16,7 @@
var util = require('../../util/util');
// Expose 'ConnectionStringParser'.
-exports = module.exports = { ConnectionStringParser: { parse: ConnectionStringParser.parse } };
+exports = module.exports = ConnectionStringParser;
/**
* Creates a new 'ConnectionString' instance.
@@ -25,7 +25,7 @@ exports = module.exports = { ConnectionStringParser: { parse: ConnectionStringP
* @param {number} connectionString The connection string to be parsed.
*/
function ConnectionStringParser(connectionString) {
- this._connectionString = connectionString;
+ this._value = connectionString;
this._pos = 0;
this._state = 'ExpectKey';
}
@@ -43,7 +43,7 @@ ConnectionStringParser.prototype._parse = function () {
for (; ;) {
this._skipWhitespaces();
- if (this._pos === this._value.Length && this._state != 'ExpectValue')
+ if (this._pos === this._value.length && this._state !== 'ExpectValue')
{
// Not stopping after the end has been reached and a value is expected
// results in creating an empty value, which we expect.
@@ -64,7 +64,7 @@ ConnectionStringParser.prototype._parse = function () {
case 'ExpectValue':
value = this._extractValue();
this._state = 'ExpectSeparator';
- parsedConnectionString[key] = value;
+ parsedConnectionString[key.toLowerCase()] = value;
key = null;
value = null;
break;
@@ -74,12 +74,11 @@ ConnectionStringParser.prototype._parse = function () {
this._state = 'ExpectKey';
break;
}
+ }
- if (this._state === 'ExpectAssignment') {
- // Must end parsing in the valid state (expected key or separator)
- throw new Error('Invalid connection string. Missing character "=".');
- }
-
+ if (this._state === 'ExpectAssignment') {
+ // Must end parsing in the valid state (expected key or separator)
+ throw new Error('Invalid connection string. Missing character "=".');
}
return parsedConnectionString;
@@ -120,7 +119,7 @@ ConnectionStringParser.prototype._extractKey = function () {
this._pos++;
}
- key = this._value.substring(firstPos, this._pos - firstPos);
+ key = this._value.substring(firstPos, this._pos);
}
if (key.length === 0) {
@@ -149,7 +148,7 @@ ConnectionStringParser.prototype._extractString = function (quote) {
throw new Error('Invalid string');
}
- return this._value.substring(firstPos, this._pos++ - firstPos);
+ return this._value.substring(firstPos, this._pos++);
};
/**
@@ -163,7 +162,7 @@ ConnectionStringParser.prototype._skipOperator = function (operatorChar) {
throw new Error('Character not expected ' + operatorChar);
}
- _pos++;
+ this._pos++;
};
/**
@@ -199,7 +198,7 @@ ConnectionStringParser.prototype._extractValue = function () {
}
}
- value = this._value.substring(firstPos, this._pos - firstPos);
+ value = this._value.substring(firstPos, this._pos);
}
}

0 comments on commit c43a810

Please sign in to comment.