GRouterJavascriptInterface { public GRouterJavascriptInterface addAccessDomain(String domain) { accessDomains.add(domain); return this; } GRouterJavascriptInterface(Activity activity); void setUrl(String url); @JavascriptInterface @Keep final String executeTask(String url); @JavascriptInterface @Keep final void startPage(String url); boolean hasAccessPermission(); GRouterJavascriptInterface addAccessDomain(String domain);  }
@Test public void addAccessDomain() { List<String> accessDomains = new ArrayList<>(); accessDomains.add("*.grouter.com"); String currentUrl = "https: if (currentUrl == null || currentUrl.length() == 0) { System.out.println("匹配失败"); return ; } try { Uri uri = Uri.parse(currentUrl); String host = uri.getHost(); for (String reg : accessDomains) { if (host.equals(reg)) { System.out.println("匹配成功"); return ; } if (reg.startsWith("*") && currentUrl.contains(reg.substring(2))) { System.out.println("匹配成功"); return ; } } }catch (Exception e){ e.printStackTrace(); } System.out.println("匹配失败"); return ; }