Skip to content

Commit

Permalink
Modify webview interception address keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
ainibawoxianzai committed Mar 3, 2022
1 parent 685f692 commit f7ecaf2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web3lib/src/main/java/coming/web3/UrlHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public interface UrlHandler {

String getSchemeSpecificPart();
String getHostPath();

String handle(Uri uri);

Expand Down
14 changes: 9 additions & 5 deletions web3lib/src/main/java/coming/web3/UrlHandlerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public class UrlHandlerManager {

public UrlHandlerManager(UrlHandler... handlers) {
for (UrlHandler urlHandler : handlers) {
this.handlers.put(urlHandler.getSchemeSpecificPart(), urlHandler);
this.handlers.put(urlHandler.getHostPath(), urlHandler);
}
}

public void add(@NonNull UrlHandler urlHandler) {
this.handlers.put(urlHandler.getSchemeSpecificPart(), urlHandler);
this.handlers.put(urlHandler.getHostPath(), urlHandler);
}

public void remove(@NonNull UrlHandler urlHandler) {
this.handlers.remove(urlHandler.getSchemeSpecificPart());
this.handlers.remove(urlHandler.getHostPath());
}

String handle(String url) {
Expand All @@ -38,7 +38,7 @@ String handle(Uri uri) {
if (uri == null) {
return null;
}
if (!handlers.containsKey(uri.getSchemeSpecificPart())) {
if (!handlers.containsKey(getHostPath(uri))) {
return uri.toString();
}
return getHandler(uri).handle(uri);
Expand All @@ -48,6 +48,10 @@ UrlHandler getHandler(Uri uri){
if (uri == null) {
return null;
}
return handlers.get(uri.getSchemeSpecificPart());
return handlers.get(getHostPath(uri));
}

String getHostPath(Uri uri){
return uri.getHost()+uri.getPath();
}
}

0 comments on commit f7ecaf2

Please sign in to comment.