Issue 309, don't fail if birthday is bad
[zxing.git] / core / src / com / google / zxing / client / result / TelResultParser.java
index 8a55759..d3f7775 100644 (file)
@@ -21,7 +21,7 @@ import com.google.zxing.Result;
 /**
  * Parses a "tel:" URI result, which specifies a phone number.
  *
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
  */
 final class TelResultParser extends ResultParser {
 
@@ -30,18 +30,15 @@ final class TelResultParser extends ResultParser {
 
   public static TelParsedResult parse(Result result) {
     String rawText = result.getText();
-    if (rawText == null || !rawText.startsWith("tel:")) {
+    if (rawText == null || (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:"))) {
       return null;
     }
-    String telURI = rawText;
+    // Normalize "TEL:" to "tel:"
+    String telURI = rawText.startsWith("TEL:") ? "tel:" + rawText.substring(4) : rawText;
     // Drop tel, query portion
     int queryStart = rawText.indexOf('?', 4);
-    if (queryStart < 0) {
-      rawText = rawText.substring(4);
-    } else {
-      rawText = rawText.substring(4, queryStart);
-    }
-    return new TelParsedResult(rawText, telURI, null);
+    String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart);
+    return new TelParsedResult(number, telURI, null);
   }
 
 }
\ No newline at end of file