GithubHelp home page GithubHelp logo

Comments (5)

addyosmani avatar addyosmani commented on May 18, 2024

This is a great catch. Nice work highlighting the normalization issue, @mathiasbynens ❀️ Given URL() has pretty decent cross-browser support, I'm happy for us to use your suggested change in some form. We probably want to sanity check if normalization should happen elsewhere in index.mjs.

Do you want to PR a fix? If not, happy to patch directly :)

from quicklink.

lukeed avatar lukeed commented on May 18, 2024

Nothing gets added to toPrefetch when you pass in an options.url list. The prefetcher only looks to remove Set entries – additions are made thru the "scraped" links which are already normalized as you mentioned.

That said, we should still probably normalize so that the prefetch itself can send valid requests. Eg, fetch('https:\\www.google.com/') will fail.

IMO, normalization should happen here: https://github.com/GoogleChromeLabs/quicklink/blob/master/src/index.mjs#L37

It'll be redundant for the "scraped" links, but it avoids adding a new function πŸ˜‡

from quicklink.

addyosmani avatar addyosmani commented on May 18, 2024

@lukeed Hah. Avoiding the addition of a new function is fair. Were you thinking of normalization around L37 looking similar to this?

function prefetcher(url) {
  const nURL = new URL(url).toString();
  toPrefetch.delete(nURL);
  prefetch(nURL, observer.priority);
}

from quicklink.

lukeed avatar lukeed commented on May 18, 2024

I blame Jason πŸ™ƒ

Was thinking this:

function prefetcher(url) {
 toPrefetch.delete(url);
 prefetch(new URL(url).toString(), observer.priority);
}

Since anything that makes its way into toPrefetch is already normalized. If we introduce some way for option.urls to coexist within the Set, then yes, the whole Set has to be normalized on entry and/or removal


Edit: We can also just do prefetch(new URL(url), priority) since fetch() will accept an URL or string & I just discovered that XHR will also work with a URL instance. πŸŽ‰

from quicklink.

addyosmani avatar addyosmani commented on May 18, 2024

Closed by #37. Thanks again!

from quicklink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.