37 lines
1.2 KiB
Java
37 lines
1.2 KiB
Java
package com.google.zxing.client.result;
|
|
|
|
import com.google.zxing.Result;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class URIResultParser extends ResultParser {
|
|
private static final Pattern e = Pattern.compile("[a-zA-Z][a-zA-Z0-9+-.]+:");
|
|
private static final Pattern f = Pattern.compile("([a-zA-Z0-9\\-]+\\.){1,6}[a-zA-Z]{2,}(:\\d{1,5})?(/|\\?|$)");
|
|
|
|
static boolean e(String str) {
|
|
if (str.contains(" ")) {
|
|
return false;
|
|
}
|
|
Matcher matcher = e.matcher(str);
|
|
if (matcher.find() && matcher.start() == 0) {
|
|
return true;
|
|
}
|
|
Matcher matcher2 = f.matcher(str);
|
|
return matcher2.find() && matcher2.start() == 0;
|
|
}
|
|
|
|
@Override // com.google.zxing.client.result.ResultParser
|
|
public URIParsedResult a(Result result) {
|
|
String b = ResultParser.b(result);
|
|
if (b.startsWith("URL:") || b.startsWith("URI:")) {
|
|
return new URIParsedResult(b.substring(4).trim(), null);
|
|
}
|
|
String trim = b.trim();
|
|
if (e(trim)) {
|
|
return new URIParsedResult(trim, null);
|
|
}
|
|
return null;
|
|
}
|
|
}
|