New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't check preconnect links #1187
base: master
Are you sure you want to change the base?
Conversation
dc397f6
to
3d10611
Compare
Preconnect links are used to establish a server connection without loading a specific resource yet. Not always do these links point to a URL that should return a 200, and they are not user-facing, i.e. they don't show up in the final rendered version of a page. Therefore, I think we should them at all; not even in `--include-verbatim` mode, as they might not point to a valid resource. Fixes #897
Huh, I don't know why this breaks a test. Somehow the parser state gets tripped up by my change. Maybe I need to reset some state. @untitaker, any ideas? |
#[test] | ||
fn test_skip_preconnect() { | ||
let input = r#" | ||
<link rel="preconnect" href="https://example.com"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding a testcase for the opposite order of attributes, <link href=... rel=...>
-- not sure at the moment if it would pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it fails.
The other, similar nofollow
feature is broken in the same way and the test fails for that, too, if I change the ordering of attributes.
I'm thinking I need to improve the attribute handling in general to make the tests pass. I would have to cache the attributes and only extract links once I'm fully done with reading all attributes for a single tag. (That's the one reason why I haven't removed html5ever support yet. I like how simple the parsing is, although it's slower of course.) |
instead of writing your own emitter you can always just read through the |
@untitaker, the way I would model it (without switching to the Does that make sense? Is there an easier way in html5gum (without |
yeah that totally makes sense. currently there's no simpler way in html5gum. I would like to have more kinds of emitters that take some of that work off of you, but when I tried to build them in the past they didn't feel general purpose enough.
…On Thu, Aug 24, 2023, at 16:44, Matthias Endler wrote:
@untitaker <https://github.com/untitaker>, the way I would model it (without switching to the `DefaultEmitter`) would be to create a `HashMap` with key being the attribute and value being a list/set of links, e.g. `{ key: "href", "value": [https://example.com] }`. When I reach the end of a tag, I check the attributes and emit the list of links if there are no excluded attributes (like `rel=prefetch`).
Does that make sense? Is there an easier way in html5gum (without `DefaultEmitter`)? It feels like the perf could suffer from the additional bookkeeping.
—
Reply to this email directly, view it on GitHub <#1187 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAGMPROI3GASJ5FLPDYNPMLXW5SDJANCNFSM6AAAAAA24YQC7A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Preconnect links are used to establish a server connection without loading a specific resource yet.
Not always do these links point to a URL that should return a 200, and they are not user-facing, i.e. they don't show up in the final rendered version of a page.
Therefore, I think we should exclude them at all; not even in
--include-verbatim
mode, as they might not point to a valid resource.
Fixes #897