Comments (5)
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.
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.
@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.
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.
Closed by #37. Thanks again!
from quicklink.
Related Issues (20)
- Allow multiple Speculation Rules HOT 6
- Unrelated Issue, please delete this.
- minConnectionType option
- Switch from mocha to uvu
- site: add SRI hashes for CDN links
- el option not working as it should HOT 1
- Fix Prerender Support HOT 4
- site: add missing `alt` attributes HOT 3
- Mark peerDependencies as optional
- site: use unique page descriptions HOT 1
- infra: Redirect www domain to root
- Document the modern bundle
- No prefetching occurs for duplicate links
- site: use the files from dist folder instead of the CDN HOT 2
- Prerendering is not working HOT 5
- withQuicklink can't not support typescript HOT 1
- Avoid Triggering Requests while offline
- quicklink.prefetch need add option crossorigin attrοΌsupport prefetch cross origin resources
- Quicklink causes desynchronizations between pages for users login and cart counter
- Update request for "quicklink" library to fix CORS errors HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quicklink.