Move matchCompatibleWith() out of while loop
diff --git a/lib/src/version_constraint.dart b/lib/src/version_constraint.dart
index ab035ff..38864aa 100644
--- a/lib/src/version_constraint.dart
+++ b/lib/src/version_constraint.dart
@@ -45,16 +45,17 @@
   ///     <=5.1.4
   ///     >2.0.4 <= 2.4.6
   factory VersionConstraint.parse(String text) {
-    // Handle the "any" constraint.
-    if (text.trim() == "any") return any;
-
     var originalText = text;
-    var constraints = [];
 
     skipWhitespace() {
       text = text.trim();
     }
 
+    skipWhitespace();
+
+    // Handle the "any" constraint.
+    if (text == "any") return any;
+
     // Try to parse and consume a version number.
     matchVersion() {
       var version = START_VERSION.firstMatch(text);
@@ -103,18 +104,19 @@
             '"$originalText", got "$text".');
       }
 
-      getCurrentTextIndex() => originalText.length - text.length;
-      var startTextIndex = getCurrentTextIndex();
-      if (constraints.isNotEmpty || text.isNotEmpty) {
-        var constraint = op + originalText.substring(startTextIndex,
-            getCurrentTextIndex());
+      if (text.isNotEmpty) {
         throw new FormatException('Cannot include other constraints with '
-            '"^" constraint "$constraint" in "$originalText".');
+            '"^" constraint in "$originalText".');
       }
 
       return new VersionConstraint.compatibleWith(version);
     }
 
+    var compatibleWith = matchCompatibleWith();
+    if (compatibleWith != null) return compatibleWith;
+
+    var constraints = [];
+
     while (true) {
       skipWhitespace();
 
@@ -132,11 +134,6 @@
         continue;
       }
 
-      var compatibleWith = matchCompatibleWith();
-      if (compatibleWith != null) {
-        return compatibleWith;
-      }
-
       // If we got here, we couldn't parse the remaining string.
       throw new FormatException('Could not parse version "$originalText". '
           'Unknown text at "$text".');