ponnamkarthik / RichLinkPreview

A Rich Link Preview Library for Android
Apache License 2.0
217 stars 58 forks source link

illegal character in path at index 0: {{metaservice.metaImage()}} #8

Open adapana opened 6 years ago

adapana commented 6 years ago

This crash happen sometimes:

Caused by java.lang.IllegalArgumentException: Illegal character in path at index 0: {{metaservice.metaImage()}} at java.net.URI.create(URI.java:734) at java.net.URI.resolve(URI.java:1264) at io.github.ponnamkarthik.richlinkpreview.RichPreview.resolveURL(SourceFile:170) at io.github.ponnamkarthik.richlinkpreview.RichPreview.access$100$421289a4(SourceFile:19) at io.github.ponnamkarthik.richlinkpreview.RichPreview$getData.doInBackground$10299ca(SourceFile:86) at io.github.ponnamkarthik.richlinkpreview.RichPreview$getData.doInBackground(SourceFile:35) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

fernandoavf7 commented 5 years ago

I have same problem, I fix with sorce code but cant push:

RichPreview.java

` private String resolveURL(String url, String part) { if(URLUtil.isValidUrl(part)) { return part; } else { URI base_uri = null; try { base_uri = new URI(url);

    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    try{
        part = fixSpecialCharacters(url, part);
        base_uri = base_uri.resolve(part);

    }catch (IllegalArgumentException i){
        i.printStackTrace();
    }
    return base_uri.toString();
}

}

private String fixSpecialCharacters(String url, String part){ if(url.contains("falabella.com") && part.contains("?")){ part = part.split("\?")[0]; }

return part;

} `