mgks / Android-SmartWebView

A simple use webview integrated w/ native features to help create most advanced hybrid applications.
https://mgks.dev/smart-webview
MIT License
570 stars 278 forks source link

Not using ASWV_EXC_LIST #187

Closed abhinavaggarwal8 closed 4 years ago

abhinavaggarwal8 commented 4 years ago

Please change line number From -: } else if (ASWP_EXTURL && !aswm_host(url).equals(ASWV_HOST)) {

To -: else if (ASWP_EXTURL && !ASWV_EXC_LIST.contains(aswm_host(url)))

So that the whitelist of domains does not end up in "tab" or "Browser"

or alternatively you can also change the method -: //Getting host name

public static Boolean aswm_host(String url) {
        if (url == null || url.length() == 0) {
            return false;
        }
        int dslash = url.indexOf("//");
        if (dslash == -1) {
            dslash = 0;
        } else {
            dslash += 2;
        }
        int end = url.indexOf('/', dslash);
        end = end >= 0 ? end : url.length();
        int port = url.indexOf(':', dslash);
        end = (port > 0 && port < end) ? port : end;
        Log.w("URL Host: ", url.substring(dslash, end));
        String domain = url.substring(dslash, end);
        for (String mDomain:ASWV_EXC_LIST) {
            if(domain.contains(mDomain)){
                return  true;
            }
        }
        return false;
    }
mgks commented 4 years ago

thanks, I've update the repo.