Fix misleading link check on texts that have something that might resemble a protocol#2714
Merged
Merged
Conversation
…oesn't have a recognized protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Context: https://stacker.news/items/1374726
Before checking if the
linkTextis misleading, we try to parse thelinkTextas a URL and check if the origin matches thehreforigin. Texts that have something that might resemble a protocol, e.g.Foo:, will fail the check even though it's not a real protocol.This PR fixes this issue by checking if
originactually got parsed, if it returns'null'then it's not a real protocol and we can move on to the second misleading check (the regex).Screenshots
tbd
Checklist
Are your changes backward compatible? Please answer below:
For example, a change is not backward compatible if you removed a GraphQL field or dropped a database column.
Yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
7, but will QA with more examples
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
n/a
Did you introduce any new environment variables? If so, call them out explicitly here:
n/a
Did you use AI for this? If so, how much did it assist you?
No, observed that
origincan be null if the protocol is nothttp(s)orftpand so on.Note
Prevents false positives in misleading link detection.
isMisleadingLinkto only comparetextUrl.origintohrefUrl.originwhentextUrl.origin !== 'null'Foo:) aren't flagged as misleadingWritten by Cursor Bugbot for commit 4afa64f. This will update automatically on new commits. Configure here.