Added support for custom URIs

This commit is contained in:
Pablo Fernandez committed 2010-10-07 21:10:32 -03:00
1 parent fbee85ec08
commit ffb1042146
3 files changed
+16 -2

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<packaging>jar</packaging>
<version>1.0.3</version>
<version>1.0.4</version>
<name>OAuth Library</name>
<dependencies>
@@ -1,10 +1,13 @@
package org.scribe.utils;
import java.util.regex.Pattern;
import org.scribe.model.OAuthConstants;
public class Preconditions
{
private static final String DEFAULT_MESSAGE = "Received an invalid parameter";
private static final Pattern URL_PATTERN = Pattern.compile("[a-zA-Z]+://\\S+");
public static void checkNotNull(Object object, String errorMsg)
{
@@ -33,7 +36,7 @@ public class Preconditions
static boolean isUrl(String url)
{
return url.startsWith("http://") || url.startsWith("https://");
return URL_PATTERN.matcher(url).matches();
}
private static void check(boolean requirements, String error)
@@ -53,6 +53,17 @@ public class PreconditionsTest
Preconditions.checkValidUrl("https://www.example.com", ERROR_MSG);
}
public void shouldAllowNonStandarProtocolsForAndroid()
{
Preconditions.checkValidUrl("myUrl://www.example.com", ERROR_MSG);
}
@Test(expected = IllegalArgumentException.class)
public void shouldNotAllowStrangeProtocolNames()
{
Preconditions.checkValidUrl("_weird*://www.example.com", ERROR_MSG);
}
public void shouldAllowOutOfBandAsValidCallbackValue()
{
Preconditions.checkValidOAuthCallback("oob", ERROR_MSG);