Skip to content
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

Invalid Links Rule #19

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Invalid Links Rule #19

wants to merge 8 commits into from

Conversation

Synvox
Copy link
Contributor

@Synvox Synvox commented Jul 11, 2018

Fixes #7

@Synvox Synvox requested a review from a team as a code owner July 11, 2018 18:05
Copy link
Contributor

@claydiffrient claydiffrient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks again for another great PR!

Copy link
Contributor

@claydiffrient claydiffrient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry @Synvox the issue wasn't super clear, but we're looking for something a little bit more robust.

This is definitely good though :)

So additionally we'd like to have it validate that the content it is linking to works. So if navigating to the link would return an error condition to the user, we'd want it to alert about that.

"Invalid links become broken links which are confusing to all users."
),

link: "https://www.w3.org/TR/2016/NOTE-WCAG20-TECHS-20161007/H48"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this link isn't linking to the proper content.

Copy link
Contributor

@claydiffrient claydiffrient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall really strong work. There are some unanswered questions I'll work with @DanaDangerGrey to track down the answers to for you.

package.json Outdated
@@ -63,6 +63,7 @@
"axios": "^0.18.0",
"format-message": "^6",
"format-message-generate-id": "^6",
"node-fetch": "^2.1.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have axios in place. It should be able to handle this same sort of thing without needing an additional library involved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sweet. I'll just use that then.

.then(res => resolve(res.ok))
.catch(() => resolve(false))

// This will always work in jest because there
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, the limitations with CORS requests from AJAX definitely cause issues here. I'm not sure we want to deal with making a service to handle this or the complexity of introducing service workers to a plugin like this.

I'll see about getting some clarification on how we want to proceed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Synvox I've talked with some stakeholders internally on how this should go... for now.. you can just go with your original "link schema checker" rather than the full on "link validator"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was thinking. It is possible to check same origin links but much more complicated to do cross-origin. There may be a way to reference a foreign resource through an <img> tag or similar, and check to see if the image fails to load because of a failing status code. It's hacky, but similar to how JSONP works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. If you wanna do some experimentation with that... that could be really cool. We do something similar to that to detect broken images in canvas-lms by adding a onerror handler to images. Kinda hacky, but maybe workable to do something like that here.(https://github.com/instructure/canvas-lms/blob/master/app/coffeescripts/behaviors/broken-images.js)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a thought. https://codepen.io/Synvox/pen/pZvYPb?editors=0012

It looks like IMG tags don't report their failure reason which makes it impossible to detect if it failed because of a 404, or if it failed because it tried to load a document instead of an image.

The alternative is to load the resource in a Worker. The worker only throws when the resource fails on the network, which is exactly what we need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at that... it seems like a good solution... they aren't supported in IE 11, but I think we could probably just let that be a restriction on the plugin. If you aren't in IE then you get a little bit more validation, otherwise you get the basic stuff.

return elem.parentNode
},

// Note, these messages are poor and should be replaced with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get some words for you here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants