Fix slight problem in heuristic for detecting URIs: accept a.singleletterdomainelement.com

git-svn-id: https://zxing.googlecode.com/svn/trunk@2108 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-01-11 14:52:53 +00:00
parent ccf169425f
commit 01c274cfd1
3 changed files with 4 additions and 3 deletions

View file

@ -37,7 +37,7 @@ public final class HttpHelper {
private static final Collection<String> REDIRECTOR_DOMAINS = new HashSet<String>(Arrays.asList(
"amzn.to", "bit.ly", "bitly.com", "fb.me", "goo.gl", "is.gd", "j.mp", "lnkd.in", "ow.ly",
"SCN.BY", "su.pr", "t.co", "tinyurl.com", "tr.im"
"R.BEETAGG.COM", "r.beetagg.com", "SCN.BY", "su.pr", "t.co", "tinyurl.com", "tr.im"
));
private HttpHelper() {

View file

@ -33,10 +33,10 @@ public final class URIResultParser extends ResultParser {
"(/|\\?|$)"; // query, path or nothing
private static final Pattern URL_WITH_PROTOCOL_PATTERN = Pattern.compile(
"[a-zA-Z0-9]{2,}://" + // protocol
"[a-zA-Z0-9\\-]{2,}(\\.[a-zA-Z0-9\\-]{2,})*" + // host name elements
"[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*" + // host name elements
PATTERN_END);
private static final Pattern URL_WITHOUT_PROTOCOL_PATTERN = Pattern.compile(
"[a-zA-Z0-9\\-]{2,}(\\.[a-zA-Z0-9\\-]{2,})+" + // host name elements
"([a-zA-Z0-9\\-]+\\.)+[a-zA-Z0-9\\-]{2,}" + // host name elements
PATTERN_END);
@Override

View file

@ -48,6 +48,7 @@ public final class URIParsedResultTestCase extends Assert {
"otpauth://remoteaccess?devaddr=00%a1b2%c3d4&devname=foo&key=bar",
null);
doTest("s3://amazon.com:8123", "s3://amazon.com:8123", null);
doTest("HTTP://R.BEETAGG.COM/?12345", "http://R.BEETAGG.COM/?12345", null);
}
@Test