mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix parsing of '12756.501'
git-svn-id: https://zxing.googlecode.com/svn/trunk@2841 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a242df0315
commit
dd79103734
|
@ -28,10 +28,9 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public final class URIResultParser extends ResultParser {
|
||||
|
||||
private static final String ALPHANUM_PART = "[a-zA-Z0-9\\-]";
|
||||
private static final Pattern URL_WITH_PROTOCOL_PATTERN = Pattern.compile("[a-zA-Z0-9]{2,}:");
|
||||
private static final Pattern URL_WITHOUT_PROTOCOL_PATTERN = Pattern.compile(
|
||||
'(' + ALPHANUM_PART + "+\\.)+" + ALPHANUM_PART + "{2,}" + // host name elements
|
||||
"([a-zA-Z0-9\\-]+\\.)+[a-zA-Z]{2,}" + // host name elements
|
||||
"(:\\d{1,5})?" + // maybe port
|
||||
"(/|\\?|$)"); // query, path or nothing
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ public final class URIParsedResultTestCase extends Assert {
|
|||
@Test
|
||||
public void testURI() {
|
||||
doTest("google.com", "http://google.com", null);
|
||||
doTest("123.com", "http://123.com", null);
|
||||
doTest("http://google.com", "http://google.com", null);
|
||||
doTest("https://google.com", "https://google.com", null);
|
||||
doTest("google.com:443", "http://google.com:443", null);
|
||||
|
@ -58,6 +59,8 @@ public final class URIParsedResultTestCase extends Assert {
|
|||
doTestNotUri(":80/");
|
||||
doTestNotUri("ABC,20.3,AB,AD");
|
||||
doTestNotUri("http://google.com?q=foo bar");
|
||||
doTestNotUri("12756.501");
|
||||
doTestNotUri("google.50");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue