-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add support for Text fragment feature (#1545) #1600
Open
thiru-appitap
wants to merge
6
commits into
lycheeverse:master
Choose a base branch
from
thiru-appitap:text-fragment
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7e1e2e1
Fragment Directive feature commit
e3e09d6
Merge branch 'lycheeverse:master' into text-fragment
thiru-appitap 1085f7c
verbose message clean-up
584f460
cargo fmt fixes commit
b6d5b5a
clippy warnings fixed for test modules
4ebb039
Merge branch 'lycheeverse:master' into text-fragment
thiru-appitap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,6 +278,9 @@ pub struct ClientBuilder { | |
/// Enable the checking of fragments in links. | ||
include_fragments: bool, | ||
|
||
/// Enable the checking of text fragment in a website | ||
include_text_fragments: bool, | ||
|
||
/// Requests run through this chain where each item in the chain | ||
/// can modify the request. A chained item can also decide to exit | ||
/// early and return a status, so that subsequent chain items are | ||
|
@@ -391,6 +394,7 @@ impl ClientBuilder { | |
self.accepted, | ||
github_client, | ||
self.require_https, | ||
self.include_text_fragments, | ||
self.plugin_request_chain, | ||
); | ||
|
||
|
@@ -665,6 +669,7 @@ mod tests { | |
// Same, but ignore certificate error | ||
let res = ClientBuilder::builder() | ||
.allow_insecure(true) | ||
.include_text_fragments(true) | ||
.build() | ||
.client() | ||
.unwrap() | ||
|
@@ -841,6 +846,65 @@ mod tests { | |
assert!(res.status().is_unsupported()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_fragment_directive() { | ||
let client = ClientBuilder::builder() | ||
.include_text_fragments(true) | ||
.build() | ||
.client() | ||
.unwrap(); | ||
|
||
// Start only | ||
println!("testing START only directive..."); | ||
let res = client.check("https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments#:~:text=without%20relying%20on%20the%20presence%20of%20IDs").await.unwrap(); | ||
assert!(res.status().is_success()); | ||
|
||
// Start and End | ||
println!("\ntesting START and END directive..."); | ||
let res = client.check("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#:~:text=linked%20URL,defining%20a%20value").await.unwrap(); | ||
assert!(res.status().is_success()); | ||
|
||
// Prefix and start | ||
println!("\ntesting Prefix with START..."); | ||
let res = client | ||
.check("https://example.com/#:~:text=asking-,for") | ||
.await | ||
.unwrap(); | ||
assert!(res.status().is_success()); | ||
|
||
// start with suffix | ||
println!("\ntesting start with suffix..."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll probably remove the |
||
let res = client.check("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#:~:text=linked%20URL\'s,-format").await.unwrap(); | ||
assert!(res.status().is_success()); | ||
|
||
let res = client.check("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#:~:text=downgrade:-,The%20Referer,be%20sent,-to%20origins").await.unwrap(); | ||
assert!(res.status().is_success()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_multiple_directives() { | ||
let client = ClientBuilder::builder() | ||
.include_text_fragments(true) | ||
.build() | ||
.client() | ||
.unwrap(); | ||
|
||
let res = client.check("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#:~:text=causes&text=linked").await.unwrap(); | ||
assert!(res.status().is_success()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn fail_fragment_directive_test() { | ||
let client = ClientBuilder::builder() | ||
.include_text_fragments(true) | ||
.build() | ||
.client() | ||
.unwrap(); | ||
|
||
let res = client.check("https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments#:~:text=without%20relying%20on%20the%20presence%20of%20DIs").await.unwrap(); | ||
assert!(res.status().is_error()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_max_redirects() { | ||
let mock_server = wiremock::MockServer::start().await; | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Maybe we can move that into a function/method?
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.
some tests for that part would also be nice