From 01c274cfd1efe38cc53e1fcf3bcc38f7567ee011 Mon Sep 17 00:00:00 2001 From: srowen Date: Wed, 11 Jan 2012 14:52:53 +0000 Subject: [PATCH] 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 --- android/src/com/google/zxing/client/android/HttpHelper.java | 2 +- core/src/com/google/zxing/client/result/URIResultParser.java | 4 ++-- .../google/zxing/client/result/URIParsedResultTestCase.java | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/android/src/com/google/zxing/client/android/HttpHelper.java b/android/src/com/google/zxing/client/android/HttpHelper.java index 23bb5895b..ba2b0792a 100644 --- a/android/src/com/google/zxing/client/android/HttpHelper.java +++ b/android/src/com/google/zxing/client/android/HttpHelper.java @@ -37,7 +37,7 @@ public final class HttpHelper { private static final Collection REDIRECTOR_DOMAINS = new HashSet(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() { diff --git a/core/src/com/google/zxing/client/result/URIResultParser.java b/core/src/com/google/zxing/client/result/URIResultParser.java index 0543f3ac7..028936358 100644 --- a/core/src/com/google/zxing/client/result/URIResultParser.java +++ b/core/src/com/google/zxing/client/result/URIResultParser.java @@ -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 diff --git a/core/test/src/com/google/zxing/client/result/URIParsedResultTestCase.java b/core/test/src/com/google/zxing/client/result/URIParsedResultTestCase.java index a38adbfe9..1c4aa87ba 100644 --- a/core/test/src/com/google/zxing/client/result/URIParsedResultTestCase.java +++ b/core/test/src/com/google/zxing/client/result/URIParsedResultTestCase.java @@ -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