From bacd9d23f6cafde8b8707df14a85a3a41be056da Mon Sep 17 00:00:00 2001 From: haoge <470368500@qq.com> Date: Wed, 31 Oct 2018 10:30:46 +0800 Subject: [PATCH] Remove auto-fill with http for not-schema url --- .../java/com/lzh/nonview/router/Router.java | 8 +++++--- .../com/lzh/nonview/router/tools/Utils.java | 19 ++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/router-api/src/main/java/com/lzh/nonview/router/Router.java b/router-api/src/main/java/com/lzh/nonview/router/Router.java index b22ec0f..93b5792 100644 --- a/router-api/src/main/java/com/lzh/nonview/router/Router.java +++ b/router-api/src/main/java/com/lzh/nonview/router/Router.java @@ -62,7 +62,7 @@ public final class Router{ private InternalCallback internalCallback; private Router(Uri uri) { - this.uri = Utils.completeUri(uri); + this.uri = uri; internalCallback = new InternalCallback(this.uri); } @@ -72,7 +72,7 @@ private Router(Uri uri) { * @return new Router */ public static Router create(String url) { - return new Router(Uri.parse(url)); + return new Router(Uri.parse(url == null?"":url)); } /** @@ -182,7 +182,9 @@ public IRoute getRoute () { private IRoute getLocalRoute() { RouteRule rule; - if ((rule = ActionRoute.findRule(uri, Cache.TYPE_ACTION_ROUTE)) != null) { + if (!Utils.isValidUri(uri)) { + return new IRoute.EmptyRoute(internalCallback); + } else if ((rule = ActionRoute.findRule(uri, Cache.TYPE_ACTION_ROUTE)) != null) { return new ActionRoute().create(uri, rule, new Bundle(), internalCallback); } else if ((rule = ActivityRoute.findRule(uri, Cache.TYPE_ACTIVITY_ROUTE)) != null) { return new ActivityRoute().create(uri, rule, new Bundle(), internalCallback); diff --git a/router-api/src/main/java/com/lzh/nonview/router/tools/Utils.java b/router-api/src/main/java/com/lzh/nonview/router/tools/Utils.java index 47f0f89..5a36679 100644 --- a/router-api/src/main/java/com/lzh/nonview/router/tools/Utils.java +++ b/router-api/src/main/java/com/lzh/nonview/router/tools/Utils.java @@ -50,21 +50,6 @@ public static String format(String url) { return url; } - /** - *
- * Check and completed the uri when it was build without a 'scheme'. - * in this case. the default scheme 'http' will be added. - *
- * @param uri source uri - * @return complete uri - */ - public static Uri completeUri(Uri uri) { - if (TextUtils.isEmpty(uri.getScheme())) { - return Uri.parse("http://" + uri.toString()); - } - return uri; - } - public static void checkInterceptor(Uri uri, RouteBundleExtras extras, Context context, List