GoogleChromeLabs / quicklink

⚡️Faster subsequent page-loads by prefetching in-viewport links during idle time
https://getquick.link
Apache License 2.0
11.02k stars 403 forks source link

net::ERR_UNKNOWN_URL_SCHEME #58

Closed MatTeague closed 5 years ago

MatTeague commented 5 years ago

Hi, I'm having an issue with quicklinks.umd when using tel links. When a tel link is used the console error is then produced:

net::ERR_UNKNOWN_URL_SCHEME

I've tried using the ignores but I just can't get it to not include tel or mailto links.

<script id="quicklink">
    window.addEventListener('load', () =>{
        quicklink({
            timeout: 4000,
            ignores: [
                /tel:/g,
                /#(.+)/,
                                 uri => uri.includes('tel:')
                (uri, elem) => elem.hasAttribute('noprefetch')
            ]
        });
    });
</script>

I just can't seem to figure it out. Any help would be appricated. Thanks

addyosmani commented 5 years ago

I put together a local test page that includes tel links and used the latest 1.0.0 UMD build. The following was working for me fine, ignoring any links with tel: in there:

  <div>
      ....
      <a href="tel:1-562-867-5309">Link 2</a>
  </div>
   <script src="../dist/quicklink.umd.js"></script>
    <script>
    window.addEventListener('load', () => {
      quicklink({
        timeout: 4000,
        ignores: [
          /tel:/g,
          /#(.+)/,
          uri => uri.includes('tel:')
        ]
      });
    });
    </script>
MatTeague commented 5 years ago

Hi @addyosmani, thank you I've just copied and pasted your code and it's working. I'm trying to see a difference between our two code snippet. As I'm not sure why mine gives the error. However, I have just noticed I missed a , from the the uri => uri.includes('tel:').

Thanks for the help!