/**
* Parses a "tel:" URI result, which specifies a phone number.
*
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
*/
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